| Crates.io | rac_rs |
| lib.rs | rac_rs |
| version | 0.1.1 |
| created_at | 2025-06-21 15:58:38.780621+00 |
| updated_at | 2025-06-26 08:40:25.713181+00 |
| description | A Rust client library for RAC (Real Address Chat) protocol. |
| homepage | https://github.com/kostya-zero/rac-rs |
| repository | https://github.com/kostya-zero/rac-rs |
| max_upload_size | |
| id | 1720911 |
| size | 91,738 |
rac-rsA Rust client library for RAC (Real Address Chat) protocol.
rac_rs provides both synchronous and asynchronous clients to interact with RAC servers. It supports both the TCP
RAC protocol and the WebSocket-based WRAC protocol.
RAC and WRAC protocols.Client) and Asynchronous (async_client) APIs.RACv2.{username} placeholder replacement.ClientError.Add this to your Cargo.toml:
[dependencies]
rac_rs = "0.1.0"
Or use bleeding-edge version from GitHub:
[dependencies]
rac_rs = { git = "https://github.com/kostya-zero/rac-rs.git" }
The crate APIs are split into separate features:
client - Synchronous client for RAC protocol.async_client - Asynchronous client for RAC protocol.wrac - Synchronous client for WRAC protocol.async_wrac - Asynchronous client for WRAC protocol.All of these features are enabled by default.
Here is a basic example of how to use the synchronous Client.
use rac_rs::client::Client;
use rac_rs::shared::{ClientError,Credentials};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let credentials = Credentials {
username: "test_user".to_string(),
password: Some("password123".to_string()),
};
let mut client = Client::new(
"127.0.0.1:42666".to_string(), // Your RAC server address
credentials,
false
);
// Test the connection
client.test_connection()?;
println!("Successfully connected to the server.");
// Register a new user (only for RACv2)
// This might fail if the user already exists.
match client.register_user() {
Ok(()) => println!("User registered successfully!"),
Err(ClientError::UsernameAlreadyTaken) => println!("Username is already taken."),
Err(e) => println!("Failed to register user: {}", e),
}
// Send a message. The `{username}` placeholder is automatically replaced.
client.send_message("<{username}> Hello from rac_rs!")?;
println!("Message sent.");
// Fetch all messages
println!("\n--- All Messages ---");
let messages = client.fetch_all_messages()?;
for msg in &messages {
println!("{}", msg);
}
// Fetch only new messages since the last fetch
println!("\n--- New Messages ---");
// In a real application, you might wait here for new messages to arrive.
let new_messages = client.fetch_new_messages()?;
if new_messages.is_empty() {
println!("No new messages.");
} else {
for msg in new_messages {
println!("{}", msg);
}
}
Ok(())
}
rac_rs:This project is licensed under the MIT License.