rac_rs/
lib.rs

1//! `rac_rs` is a Rust implementation of a client for RAC (Real Address Chat) protocol.
2//!
3//! This crate provides a `Client` to interact with RAC servers, allowing you to:
4//! - Connect to a server.
5//! - Send and receive messages.
6//! - Register new users.
7//!
8//! It supports both RAC and WRAC protocols.
9//!
10//! This crate is split into separate features which provide different functionality:
11//!
12//! - `client` - Synchronous client for RAC protocol.
13//! - `async_client` - Asynchronous client for RAC protocol.
14//! - `wrac` - Synchronous client for WRAC protocol.
15//! - `async_wrac` - Asynchronous client for WRAC protocol.
16//!
17//! By default, all of these features are enabled.
18//!
19//! # Example
20//!
21//! ```no_run
22//! use rac_rs::client::Client;
23//! use rac_rs::shared::Credentials;
24//!
25//! fn main() -> Result<(), Box<dyn std::error::Error>> {
26//!     let credentials = Credentials {
27//!         username: "test_user".to_string(),
28//!         password: Some("password123".to_string()),
29//!     };
30//!
31//!     let mut client = Client::new(
32//!         "127.0.0.1:42666".to_string(),
33//!         credentials,
34//!         false
35//!     );
36//!
37//!     // Test the connection
38//!     client.test_connection()?;
39//!
40//!     // Register a new user (for RACv2)
41//!     // client.register_user()?;
42//!
43//!     // Send a message
44//!     client.send_message("<{username}> Hello everyone!")?;
45//!
46//!     // Fetch all messages
47//!     let messages = client.fetch_all_messages()?;
48//!     for msg in messages {
49//!         println!("{}", msg);
50//!     }
51//!
52//!     Ok(())
53//! }
54//! ```
55
56/// Contains the client implementation for interacting with RAC servers.
57#[cfg(feature = "client")]
58pub mod client;
59
60/// Contains the async client implementation for interacting with RAC servers.
61#[cfg(feature = "async_client")]
62pub mod async_client;
63
64/// Contains shared type and utilities that's used across the library.
65pub mod shared;
66
67/// Contains the implementation of the WRAC protocol, which is a WebSocket-based version of the RAC protocol.
68#[cfg(feature = "wrac")]
69pub mod wrac;
70
71/// Contains the async implementation of the WRAC protocol.
72#[cfg(feature = "async_wrac")]
73pub mod async_wrac;