Handler

Trait Handler 

Source
pub trait Handler<ParamTy, State: Clone + Send + Sync + 'static> {
    type Future: Future<Output = Result<Response, CatBridgeError>> + Send + 'static;

    // Required method
    fn call(self, req: Request<State>) -> Self::Future;
}
Available on (crate features clients or servers) and crate feature servers only.
Expand description

A route handler, attempts to be an incredibly thin layer between a function, and the actual ending handler.

Implemented so we can implement for function that accepts any varying amount of args of types that implement from request parts.

ParamTy is kept to prevent generation of conflicting type implementations of this trait. It however is not actually needed by any of our code.

Required Associated Types§

Source

type Future: Future<Output = Result<Response, CatBridgeError>> + Send + 'static

Required Methods§

Source

fn call(self, req: Request<State>) -> Self::Future

Implementors§

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1> Handler<(T1,), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2> Handler<(T1, T2), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3> Handler<(T1, T2, T3), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4> Handler<(T1, T2, T3, T4), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5> Handler<(T1, T2, T3, T4, T5), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6> Handler<(T1, T2, T3, T4, T5, T6), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7> Handler<(T1, T2, T3, T4, T5, T6, T7), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8> Handler<(T1, T2, T3, T4, T5, T6, T7, T8), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequestParts<State> + Send, T10: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequestParts<State> + Send, T10: FromRequestParts<State> + Send, T11: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequestParts<State> + Send, T10: FromRequestParts<State> + Send, T11: FromRequestParts<State> + Send, T12: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequestParts<State> + Send, T10: FromRequestParts<State> + Send, T11: FromRequestParts<State> + Send, T12: FromRequestParts<State> + Send, T13: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequestParts<State> + Send, T10: FromRequestParts<State> + Send, T11: FromRequestParts<State> + Send, T12: FromRequestParts<State> + Send, T13: FromRequestParts<State> + Send, T14: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequestParts<State> + Send, T10: FromRequestParts<State> + Send, T11: FromRequestParts<State> + Send, T12: FromRequestParts<State> + Send, T13: FromRequestParts<State> + Send, T14: FromRequestParts<State> + Send, T15: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, OutputTy, State: Clone + Send + Sync + 'static, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Handler<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = OutputTy> + Send, OutputTy: IntoResponse, T1: FromRequestParts<State> + Send, T2: FromRequestParts<State> + Send, T3: FromRequestParts<State> + Send, T4: FromRequestParts<State> + Send, T5: FromRequestParts<State> + Send, T6: FromRequestParts<State> + Send, T7: FromRequestParts<State> + Send, T8: FromRequestParts<State> + Send, T9: FromRequestParts<State> + Send, T10: FromRequestParts<State> + Send, T11: FromRequestParts<State> + Send, T12: FromRequestParts<State> + Send, T13: FromRequestParts<State> + Send, T14: FromRequestParts<State> + Send, T15: FromRequestParts<State> + Send, T16: FromRequest<State> + Send,

Source§

impl<UnderlyingFnType, FnFutureTy, ResponseTy, State: Clone + Send + Sync + 'static> Handler<(), State> for UnderlyingFnType
where UnderlyingFnType: FnOnce() -> FnFutureTy + Clone + Send + 'static, FnFutureTy: Future<Output = ResponseTy> + Send, ResponseTy: IntoResponse,

Allow any async function without arguments to be a handler