pub trait Handler<P: Provider>: Sized {
type Input;
type Output: Body;
type Error: Error + Send + Sync;
// Required methods
fn from_input(input: Self::Input) -> Result<Self, Self::Error>;
fn handle(
self,
ctx: Context<'_, P>,
) -> impl Future<Output = Result<Reply<Self::Output>, Self::Error>> + Send;
// Provided method
fn handler(
input: Self::Input,
) -> Result<RequestHandler<RequestSet<Self, P>, NoOwner, NoProvider>, Self::Error> { ... }
}Expand description
Trait to provide a common interface for request handling.
Required Associated Types§
Required Methods§
Sourcefn from_input(input: Self::Input) -> Result<Self, Self::Error>
fn from_input(input: Self::Input) -> Result<Self, Self::Error>
Provided Methods§
Sourcefn handler(
input: Self::Input,
) -> Result<RequestHandler<RequestSet<Self, P>, NoOwner, NoProvider>, Self::Error>
fn handler( input: Self::Input, ) -> Result<RequestHandler<RequestSet<Self, P>, NoOwner, NoProvider>, Self::Error>
Initialize a [RequestHandler] from raw request.
§Errors
Returns an error if the message cannot be decoded.
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.