Endpoint

Trait Endpoint 

Source
pub trait Endpoint<Req: DeserializeOwned + Send + 'static, Resp: Serialize>: Send + Sync {
    // Required method
    fn respond<'life0, 'async_trait>(
        &'life0 self,
        req: Request<Req>,
    ) -> Pin<Box<dyn Future<Output = Result<Resp>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

An Endpoint asynchronously responds to Requests.

Required Methods§

Source

fn respond<'life0, 'async_trait>( &'life0 self, req: Request<Req>, ) -> Pin<Box<dyn Future<Output = Result<Resp>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a request. This should not block. Implementations should do things like move the Request to background tasks/threads to avoid this.

Implementors§

Source§

impl<Req: DeserializeOwned + Send + 'static, Resp: Serialize, F: Fn(Request<Req>) -> R + 'static + Send + Sync, R: Future<Output = Result<Resp>> + Send + 'static> Endpoint<Req, Resp> for F