Skip to main content

toolkit_zero/socket/
prelude.rs

1
2//! Convenience re-exports for the `socket` module.
3//!
4//! Importing this prelude brings the most commonly used server and client
5//! types into scope through a single `use` path:
6//!
7//! ```rust,no_run
8//! use toolkit_zero::socket::prelude::*;
9//! # use toolkit_zero::socket::server::reply;
10//!
11//! // Server types — fluent builder
12//! let mut server = Server::default();
13//! server.mechanism(ServerMechanism::get("/health").onconnect(|| async { reply!() }));
14//!
15//! // Server types — attribute macro shorthand
16//! #[mechanism(server, GET, "/hello")]
17//! async fn hello() { reply!() }
18//!
19//! // Client types
20//! let client = Client::new(Target::Localhost(8080));
21//! ```
22//!
23//! Re-exports are gated by feature flags:
24//! - `socket-server` / `socket`: [`Server`], [`ServerMechanism`], [`Status`], [`mechanism`]
25//! - `socket-client` / `socket`: [`Client`], [`ClientError`], [`Target`], [`request`]
26//! - always available: [`SerializationKey`]
27
28pub use crate::socket::SerializationKey;
29
30#[cfg(any(feature = "socket", feature = "socket-server"))]
31pub use crate::socket::server::{Server, ServerMechanism, Status, mechanism};
32
33#[cfg(any(feature = "socket", feature = "socket-client"))]
34pub use crate::socket::client::{Client, ClientBuilder, ClientError, Target, request};