[−][src]Trait roa::Endpoint
Endpoint
There are two kinds of endpoints, the one is functional endpoints, the another is trait endpoints.
Functional Endpoints
A normal functional endpoint is an object implements Fn
trait:
use roa_core::{Context, Next, 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);
Closures are also supported, but feature(async_closure) is required:
Trait Endpoints
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
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + '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<(), Error>> + 'async_trait>> where
'a: 'async_trait,
(): 'async_trait,
[src]
&'a self,
_ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
(): 'async_trait,
impl<'a, S> Endpoint<'a, S> for Dispatcher<S> where
S: 'static,
S: 'static,
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Dispatcher<S>: 'async_trait,
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Dispatcher<S>: 'async_trait,
impl<'a, S, E> Endpoint<'a, S> for Guard<E> where
E: Endpoint<'a, S>,
E: Endpoint<'a, S>,
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Guard<E>: 'async_trait,
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Guard<E>: 'async_trait,
impl<'a, S> Endpoint<'a, S> for RouteTable<S> where
S: 'static,
S: 'static,
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
RouteTable<S>: 'async_trait,
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
RouteTable<S>: 'async_trait,
impl<'a, F, S, Fut> Endpoint<'a, S> for Websocket<F, S, Fut> where
F: 'static + Sync + Send + Fn(Context<S>, WebSocketStream<Upgraded>) -> Fut,
Fut: 'static + Send + Future<Output = ()>,
S: State,
F: 'static + Sync + Send + Fn(Context<S>, WebSocketStream<Upgraded>) -> Fut,
Fut: 'static + Send + Future<Output = ()>,
S: State,
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Websocket<F, S, Fut>: 'async_trait,
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Websocket<F, S, Fut>: '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<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Boxed<S>: 'async_trait,
[src]
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
Boxed<S>: 'async_trait,
impl<'a, S, T, F> Endpoint<'a, S> for T where
F: 'a + Future<Output = Result<(), Error>>,
S: 'a,
T: 'static + Send + Sync + Fn(&'a mut Context<S>) -> F,
[src]
F: 'a + Future<Output = Result<(), Error>>,
S: 'a,
T: 'static + Send + Sync + Fn(&'a mut Context<S>) -> F,
fn call<'async_trait>(
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
T: 'async_trait,
[src]
&'a self,
ctx: &'a mut Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
'a: 'async_trait,
T: 'async_trait,
impl<'a, S, T, U> Endpoint<'a, S> for Chain<T, U> where
T: Middleware<'b, S>,
U: Endpoint<'a, S>,
[src]
T: Middleware<'b, S>,
U: Endpoint<'a, S>,