Skip to main content

Module prelude

Module prelude 

Source
Expand description

Convenience re-exports for the socket module.

Importing this prelude brings the most commonly used server and client types into scope through a single use path:

use toolkit_zero::socket::prelude::*;

// Server types — fluent builder
let mut server = Server::default();
server.mechanism(ServerMechanism::get("/health").onconnect(|| async { reply!() }));

// Server types — attribute macro shorthand
#[mechanism(server, GET, "/hello")]
async fn hello() { reply!() }

// Client types
let client = Client::new(Target::Localhost(8080));

Re-exports are gated by feature flags:

Re-exports§

pub use crate::socket::SerializationKey;
pub use crate::socket::server::Server;
pub use crate::socket::server::ServerMechanism;
pub use crate::socket::server::Status;
pub use crate::socket::client::Client;
pub use crate::socket::client::ClientError;
pub use crate::socket::client::Target;

Attribute Macros§

mechanism
Declare a server-side route.
request
Emit an inline HTTP request and bind the response.