Trait Server

pub trait Server<Error, InputStreamError = Error, OutputStreamError = Error> {
    type Request: Req<Error, InputStreamError, OutputStreamError, WebsocketResponse = Self::Response> + Send + 'static;
    type Response: Res + TryRes<Error> + Send + 'static;

    // Required method
    fn spawn(
        future: impl Future<Output = ()> + Send + 'static,
    ) -> Result<(), Error>;
}
Expand description

A server defines a pair of request/response types and the logic to spawn an async task.

This trait is implemented for any server backend for server functions including axum and actix-web. It should almost never be necessary to implement it yourself, unless you’re trying to use an alternative HTTP server.

Required Associated Types§

type Request: Req<Error, InputStreamError, OutputStreamError, WebsocketResponse = Self::Response> + Send + 'static

The type of the HTTP request when received by the server function on the server side.

type Response: Res + TryRes<Error> + Send + 'static

The type of the HTTP response returned by the server function on the server side.

Required Methods§

fn spawn(future: impl Future<Output = ()> + Send + 'static) -> Result<(), Error>

Spawn an async task on the server.

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§

§

impl<Error, InputStreamError, OutputStreamError> Server<Error, InputStreamError, OutputStreamError> for AxumServerFnBackend
where Error: FromServerFnError + Send + Sync, InputStreamError: FromServerFnError + Send + Sync, OutputStreamError: FromServerFnError + Send + Sync,

§

impl<Error, InputStreamError, OutputStreamError> Server<Error, InputStreamError, OutputStreamError> for BrowserMockServer
where Error: Send + 'static, InputStreamError: Send + 'static, OutputStreamError: Send + 'static,