Handler

Trait Handler 

Source
pub trait Handler {
    type Error<E>: Debug
       where E: Debug;

    // Required method
    async fn handle<T, const N: usize>(
        &self,
        task_id: impl Display + Copy,
        connection: &mut Connection<'_, T, N>,
    ) -> Result<(), Self::Error<T::Error>>
       where T: Read + Write + TcpSplit;
}
Expand description

A trait (async callback) for handling incoming HTTP requests

Required Associated Types§

Source

type Error<E>: Debug where E: Debug

Required Methods§

Source

async fn handle<T, const N: usize>( &self, task_id: impl Display + Copy, connection: &mut Connection<'_, T, N>, ) -> Result<(), Self::Error<T::Error>>
where T: Read + Write + TcpSplit,

Handle an incoming HTTP request

Parameters:

  • task_id: An identifier for the task, thast can be used by the handler for logging purposes
  • connection: A connection state machine for the request-response cycle

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.

Implementations on Foreign Types§

Source§

impl<H> Handler for &H
where H: Handler,

Source§

type Error<E> = <H as Handler>::Error<E> where E: Debug

Source§

async fn handle<T, const N: usize>( &self, task_id: impl Display + Copy, connection: &mut Connection<'_, T, N>, ) -> Result<(), Self::Error<T::Error>>
where T: Read + Write + TcpSplit,

Source§

impl<H> Handler for &mut H
where H: Handler,

Source§

type Error<E> = <H as Handler>::Error<E> where E: Debug

Source§

async fn handle<T, const N: usize>( &self, task_id: impl Display + Copy, connection: &mut Connection<'_, T, N>, ) -> Result<(), Self::Error<T::Error>>
where T: Read + Write + TcpSplit,

Source§

impl<H> Handler for WithTimeout<H>
where H: Handler,

Source§

type Error<E> = WithTimeoutError<<H as Handler>::Error<E>> where E: Debug

Source§

async fn handle<T, const N: usize>( &self, task_id: impl Display + Copy, connection: &mut Connection<'_, T, N>, ) -> Result<(), Self::Error<T::Error>>
where T: Read + Write + TcpSplit,

Implementors§