Skip to main content

Command

Trait Command 

Source
pub trait Command {
    type Request: Decode;

    // Required method
    async fn serve(
        ctx: IoContext<Accepted, Bare>,
        req: Self::Request,
        res: &mut Resources<'_>,
    ) -> Outcome;
}
Expand description

One command’s server-side behaviour: map its owned request to an Outcome, using the connection/server Resources. Dispatched by a concrete match (never as a trait object), so it uses native async fn and needs no boxed future.

Required Associated Types§

Source

type Request: Decode

The request type this command decodes and consumes.

Required Methods§

Source

async fn serve( ctx: IoContext<Accepted, Bare>, req: Self::Request, res: &mut Resources<'_>, ) -> Outcome

Serve the request. The context is request-neutral (Bare) and owns everything except the request and the shared resources, passed alongside.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§