This project is a simple asynchronous chat server and CLI client built in Rust. It was developed as a Rust job assignment to demonstrate proficiency in async Rust.
I used Tokio channels, Arc smart pointers for thread-safe sharing of state, and utilise the actor pattern to prevent deadlocks.
- Single Room Chat: Users can join, leave, and send messages in a single chat room.
- High Throughput: Designed for maximum concurrency with non-blocking code.
- Unique Usernames: Ensures each user has a unique identifier.
- Efficient Resource Usage: Supports many users with minimal delay and memory footprint.
- Async Rust: Async runtime for polling the top-level Future.
- Smart Pointer & Thread-safe data structure (Arc): To manage shared state safely between tasks.
- Tokio Channels: For message passing between tasks.
- Manage users and their messages.
- Process join, leave, and message commands.
- Broadcast messages to all users except the sender.
- Clean up resources when users leave or disconnect.
- Support many users efficiently.
- Async CLI program for user interaction.
- Connects to server using host and port from environment variables or command line arguments.
- Interactive command prompt with:
-
send <MSG>
: Send a message to the server. -
leave
: Disconnect from the server and exit.
-
- Include unit and integration tests.
- Format code using the standard tool.
- Ensure code compiles without clippy errors.
- Pre-commit hook for code formatting and error checking.
- GitHub Action to test server-client interaction on code push.
- Fork this repository to your GitHub account.
- Submit a pull request to our repository.
- Include a demo video at the top of the pull request.
- Submit the pull request link for review.
- Rust installed on your machine.
cargo run --bin server
cargo run --bin client
cargo test