1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Implementation of the Imagine network protocol.
//!
//! Provides a way to interact with Imagine over a IP network. It reflects the protocol and it's original implementation
//! by providing two types of a [`Connection`](network::Connection): a [`Server`](server::Server), which binds to a socket,
//! and a [`Client`](client::Client), which connects to one.
//!
//! All connected users (the server and clients) are identified by a unique nickname and can exchange data in form of
//! [`Message`](network::Message)s. Anything that happens during a connection, like recieving a message or a nickname
//! change, is represented by a [`Event`](network::Event).
//!
//! # Example: Echo messages back
//!
//! ```
//! let mut network: Client = Connection::connect("127.0.0.1:1060", "imaginet").await?;
//! while let Some(event_result) = network.next().await {
//!     match event_result? {
//!         Event::RecievedMessage { sender, message }
//!             => network.send(message, vec![sender]).await?,
//!         _ => (),
//!     }
//! }
//! ```

#![warn(missing_docs)]

mod parser;
mod packet;
pub mod network;
pub mod client;
pub mod server;

const BYTE_BUFFER_SIZE: usize = 128;
const MPSC_BUFFER_SIZE: usize = 8;