Trait gotham::middleware::NewMiddleware [] [src]

pub trait NewMiddleware: Sync + RefUnwindSafe {
    type Instance: Middleware;
    fn new_middleware(&self) -> Result<Self::Instance>;
}

A type which is used to spawn new Middleware values. When implementing a Middleware, this defines how instances of the Middleware are created.

This can be derived by Middleware that implement Clone, and will result in the following implementation:

struct MyMiddleware;

impl NewMiddleware for MyMiddleware {
    type Instance = Self;

    fn new_middleware(&self) -> io::Result<Self::Instance> {
        Ok(self.clone())
    }
}

Associated Types

The type of Middleware created by the NewMiddleware.

Required Methods

Create and return a new Middleware value.

Implementors