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 34 35 36 37 38 39 40 41 42 43
//! # Overview //! //! The goal of this crate is to provide a collection of async sockets which can be used out of the //! box with `mio` event loop. As a simple example, using stream based protocols will require some //! sort of mechanism to determine the boundaries of a message etc., and this crate provides default //! implementation to handle those and abstract the boilerplate from the user libs. #[macro_use] extern crate log; #[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))] #[macro_use] extern crate quick_error; #[macro_use] extern crate serde_derive; #[macro_use] extern crate unwrap; extern crate byteorder; extern crate maidsafe_utilities; extern crate mio; extern crate net2; extern crate serde; pub use error::SocketError; pub use tcp_sock::TcpSock; mod error; mod tcp_sock; mod udt_sock; /// Priority of a message to be sent by Crust. A lower value means a higher priority, so Priority 0 /// is the highest one. Low-priority messages will be preempted if need be to allow higher priority /// messages through. Messages with a value `>= MSG_DROP_PRIORITY` will even be dropped, if /// bandwidth is insufficient. pub type Priority = u8; pub const MAX_PAYLOAD_SIZE: usize = 2 * 1024 * 1024; /// Minimum priority for droppable messages. Messages with lower values will never be dropped. pub const MSG_DROP_PRIORITY: u8 = 2; /// Maximum age of a message waiting to be sent. If a message is older, the queue is dropped. pub const MAX_MSG_AGE_SECS: u64 = 60; /// `Result` type specialised for this crate pub type Res<T> = Result<T, SocketError>;