Skip to main content

typhoon/socket/
mod.rs

1//! Client and server socket APIs.
2//!
3//! **Client**: build a [`ClientSocket`] with [`ClientSocketBuilder`]; call `send_bytes` / `receive_bytes`.
4//!
5//! **Server**: build a [`Listener`] with [`ListenerBuilder`], call `start()`, then `accept()` in a
6//! loop to obtain [`ClientHandle`]s. Each handle corresponds to one connected client.
7//!
8//! Decoy providers can be customised per-flow on the server (via [`ServerFlowConfiguration::with_decoy`])
9//! or globally on the builder (via `with_decoy` / `with_decoy_factory`). The default is
10//! `random_decoy_factory()`, which selects among all five built-in providers at random.
11
12#[cfg(feature = "client")]
13mod client;
14mod error;
15#[cfg(feature = "server")]
16mod server;
17
18use cfg_if::cfg_if;
19
20cfg_if! {
21    if #[cfg(feature = "client")] {
22        pub use client::{ClientSocket, ClientSocketBuilder};
23        pub use error::ClientSocketError;
24        pub use crate::certificate::ClientCertificate;
25        pub use crate::tailer::ClientConnectionHandler;
26    }
27}
28cfg_if! {
29    if #[cfg(feature = "server")] {
30        pub use error::ServerSocketError;
31        pub use server::{ClientHandle, Listener, ListenerBuilder, ServerFlowConfiguration};
32        pub use crate::certificate::ServerKeyPair;
33        pub use crate::tailer::ServerConnectionHandler;
34    }
35}