pub trait Handler<Req, Res>:
Send
+ Sync
+ 'static{
type Body: Encodable<Res> + Send + 'static;
// Required method
fn call(
&self,
ctx: RequestContext,
request: Req,
) -> BoxFuture<'static, ServiceResult<Self::Body>>;
}Expand description
Trait for unary RPC handlers (owned request type).
Handlers return a Response<Self::Body> where
Body is any type Encodable as Res — typically Res itself.
The happy path is Ok(res.into()).
Required Associated Types§
Sourcetype Body: Encodable<Res> + Send + 'static
type Body: Encodable<Res> + Send + 'static
The response body type. Typically Res, or any
Encodable<Res> (e.g.
MaybeBorrowed).
Required Methods§
Sourcefn call(
&self,
ctx: RequestContext,
request: Req,
) -> BoxFuture<'static, ServiceResult<Self::Body>>
fn call( &self, ctx: RequestContext, request: Req, ) -> BoxFuture<'static, ServiceResult<Self::Body>>
Handle a unary RPC request.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".