[−][src]Trait roa_core::Endpoint
Endpoint
There are two kinds of endpoint, the one is functional endpoint, the another is trait endpoint.
Functional Endpoint
A normal functional endpoint is an async function with signature:
async fn(&mut Context) -> Result
.
use roa_core::{Context, Result, Endpoint}; use std::future::Future; fn is_endpoint<S>(endpoint: impl for<'a> Endpoint<'a, S>) { } async fn endpoint(ctx: &mut Context) -> Result { Ok(()) } is_endpoint(endpoint);
Trait Endpoint
A trait endpoint is an object implementing trait Endpoint
.
use roa_core::{Endpoint, Context, Next, Result, async_trait}; use async_std::sync::Arc; use std::time::Instant; fn is_endpoint<S>(endpoint: impl for<'a> Endpoint<'a, S>) { } struct Logger; #[async_trait(?Send)] impl <'a> Endpoint<'a, ()> for Logger { async fn call(&'a self, ctx: &'a mut Context) -> Result { Ok(()) } } is_endpoint(Logger);
Required methods
#[must_use]fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
Call this endpoint.
Implementations on Foreign Types
impl<'a, S> Endpoint<'a, S> for ()
[src]
Fake endpoint.
fn call<'async_trait>(
&'a self,
_ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
[src]
&'a self,
_ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
Implementors
impl<'a, S> Endpoint<'a, S> for Boxed<S> where
S: 'static,
[src]
S: 'static,
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
[src]
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
impl<'a, S, T, F> Endpoint<'a, S> for T where
S: 'a,
T: 'static + Send + Sync + Fn(&'a mut Context<S>) -> F,
F: 'a + Future<Output = Result>,
[src]
S: 'a,
T: 'static + Send + Sync + Fn(&'a mut Context<S>) -> F,
F: 'a + Future<Output = Result>,
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
[src]
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
impl<'a, S, T, U> Endpoint<'a, S> for Chain<T, U> where
U: Endpoint<'a, S>,
T: for<'b> Middleware<'b, S>,
[src]
U: Endpoint<'a, S>,
T: for<'b> Middleware<'b, S>,