Trait Serve

Source
pub trait Serve<Req>: Sized + Clone {
    type Resp;
    type Fut: Future<Output = Self::Resp>;

    // Required method
    fn serve(self, ctx: Context, req: Req) -> Self::Fut;
}
Expand description

Basically a Fn(Req) -> impl Future<Output = Resp>;

Required Associated Types§

Source

type Resp

Type of response.

Source

type Fut: Future<Output = Self::Resp>

Type of response future.

Required Methods§

Source

fn serve(self, ctx: Context, req: Req) -> Self::Fut

Responds to a single request.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Req, Resp, Fut, F> Serve<Req> for F
where F: FnOnce(Context, Req) -> Fut + Clone, Fut: Future<Output = Resp>,

Source§

type Resp = Resp

Source§

type Fut = Fut