[][src]Trait jsonrpc_core::middleware::Middleware

pub trait Middleware<M: Metadata>: Send + Sync + 'static {
    type Future: Future<Item = Option<Response>, Error = ()> + Send + 'static;
    type CallFuture: Future<Item = Option<Output>, Error = ()> + Send + 'static;
    fn on_request<F, X>(
        &self,
        request: Request,
        meta: M,
        next: F
    ) -> Either<Self::Future, X>
    where
        F: Fn(Request, M) -> X + Send + Sync,
        X: Future<Item = Option<Response>, Error = ()> + Send + 'static
, { ... }
fn on_call<F, X>(
        &self,
        call: Call,
        meta: M,
        next: F
    ) -> Either<Self::CallFuture, X>
    where
        F: Fn(Call, M) -> X + Send + Sync,
        X: Future<Item = Option<Output>, Error = ()> + Send + 'static
, { ... } }

RPC middleware

Associated Types

type Future: Future<Item = Option<Response>, Error = ()> + Send + 'static

A returned request future.

type CallFuture: Future<Item = Option<Output>, Error = ()> + Send + 'static

A returned call future.

Loading content...

Provided methods

fn on_request<F, X>(
    &self,
    request: Request,
    meta: M,
    next: F
) -> Either<Self::Future, X> where
    F: Fn(Request, M) -> X + Send + Sync,
    X: Future<Item = Option<Response>, Error = ()> + Send + 'static, 

Method invoked on each request. Allows you to either respond directly (without executing RPC call) or do any additional work before and/or after processing the request.

fn on_call<F, X>(
    &self,
    call: Call,
    meta: M,
    next: F
) -> Either<Self::CallFuture, X> where
    F: Fn(Call, M) -> X + Send + Sync,
    X: Future<Item = Option<Output>, Error = ()> + Send + 'static, 

Method invoked on each call inside a request.

Allows you to either handle the call directly (without executing RPC call).

Loading content...

Implementations on Foreign Types

impl<M: Metadata, A: Middleware<M>, B: Middleware<M>> Middleware<M> for (A, B)[src]

type Future = Either<A::Future, B::Future>

type CallFuture = Either<A::CallFuture, B::CallFuture>

impl<M: Metadata, A: Middleware<M>, B: Middleware<M>, C: Middleware<M>> Middleware<M> for (A, B, C)[src]

type Future = Either<A::Future, Either<B::Future, C::Future>>

type CallFuture = Either<A::CallFuture, Either<B::CallFuture, C::CallFuture>>

impl<M: Metadata, A: Middleware<M>, B: Middleware<M>, C: Middleware<M>, D: Middleware<M>> Middleware<M> for (A, B, C, D)[src]

type Future = Either<A::Future, Either<B::Future, Either<C::Future, D::Future>>>

type CallFuture = Either<A::CallFuture, Either<B::CallFuture, Either<C::CallFuture, D::CallFuture>>>

Loading content...

Implementors

impl<M: Metadata> Middleware<M> for Noop[src]

Loading content...