Struct jsonrpc_core::MetaIoHandler
source · pub struct MetaIoHandler<T: Metadata, S: Middleware<T> = Noop> { /* private fields */ }
Expand description
Request handler
By default compatible only with jsonrpc v2
Implementations§
source§impl<T: Metadata> MetaIoHandler<T>
impl<T: Metadata> MetaIoHandler<T>
sourcepub fn with_compatibility(compatibility: Compatibility) -> Self
pub fn with_compatibility(compatibility: Compatibility) -> Self
Creates new MetaIoHandler
compatible with specified protocol version.
source§impl<T: Metadata, S: Middleware<T>> MetaIoHandler<T, S>
impl<T: Metadata, S: Middleware<T>> MetaIoHandler<T, S>
sourcepub fn new(compatibility: Compatibility, middleware: S) -> Self
pub fn new(compatibility: Compatibility, middleware: S) -> Self
Creates new MetaIoHandler
sourcepub fn with_middleware(middleware: S) -> Self
pub fn with_middleware(middleware: S) -> Self
Creates new MetaIoHandler
with specified middleware.
sourcepub fn add_sync_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSync,
pub fn add_sync_method<F>(&mut self, name: &str, method: F)where F: RpcMethodSync,
Adds new supported synchronous method.
A backward-compatible wrapper.
sourcepub fn add_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSimple,
pub fn add_method<F>(&mut self, name: &str, method: F)where F: RpcMethodSimple,
Adds new supported asynchronous method.
sourcepub fn add_notification<F>(&mut self, name: &str, notification: F)where
F: RpcNotificationSimple,
pub fn add_notification<F>(&mut self, name: &str, notification: F)where F: RpcNotificationSimple,
Adds new supported notification
sourcepub fn add_method_with_meta<F>(&mut self, name: &str, method: F)where
F: RpcMethod<T>,
pub fn add_method_with_meta<F>(&mut self, name: &str, method: F)where F: RpcMethod<T>,
Adds new supported asynchronous method with metadata support.
sourcepub fn add_notification_with_meta<F>(&mut self, name: &str, notification: F)where
F: RpcNotification<T>,
pub fn add_notification_with_meta<F>(&mut self, name: &str, notification: F)where F: RpcNotification<T>,
Adds new supported notification with metadata support.
sourcepub fn extend_with<F>(&mut self, methods: F)where
F: IntoIterator<Item = (String, RemoteProcedure<T>)>,
pub fn extend_with<F>(&mut self, methods: F)where F: IntoIterator<Item = (String, RemoteProcedure<T>)>,
Extend this MetaIoHandler
with methods defined elsewhere.
sourcepub fn handle_request_sync(&self, request: &str, meta: T) -> Option<String>
pub fn handle_request_sync(&self, request: &str, meta: T) -> Option<String>
Handle given request synchronously - will block until response is available.
If you have any asynchronous methods in your RPC it is much wiser to use
handle_request
instead and deal with asynchronous requests in a non-blocking fashion.
sourcepub fn handle_request(
&self,
request: &str,
meta: T
) -> FutureResult<S::Future, S::CallFuture>
pub fn handle_request( &self, request: &str, meta: T ) -> FutureResult<S::Future, S::CallFuture>
Handle given request asynchronously.
sourcepub fn handle_rpc_request(
&self,
request: Request,
meta: T
) -> FutureRpcResult<S::Future, S::CallFuture>
pub fn handle_rpc_request( &self, request: Request, meta: T ) -> FutureRpcResult<S::Future, S::CallFuture>
Handle deserialized RPC request.
sourcepub fn handle_call(
&self,
call: Call,
meta: T
) -> Either<S::CallFuture, Either<FutureOutput, Ready<Option<Output>>>> ⓘ
pub fn handle_call( &self, call: Call, meta: T ) -> Either<S::CallFuture, Either<FutureOutput, Ready<Option<Output>>>> ⓘ
Handle single call asynchronously.
sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &RemoteProcedure<T>)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &RemoteProcedure<T>)>
Returns an iterator visiting all methods in arbitrary order.
Trait Implementations§
source§impl<T: Clone + Metadata, S: Clone + Middleware<T>> Clone for MetaIoHandler<T, S>
impl<T: Clone + Metadata, S: Clone + Middleware<T>> Clone for MetaIoHandler<T, S>
source§fn clone(&self) -> MetaIoHandler<T, S>
fn clone(&self) -> MetaIoHandler<T, S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug + Metadata, S: Debug + Middleware<T>> Debug for MetaIoHandler<T, S>
impl<T: Debug + Metadata, S: Debug + Middleware<T>> Debug for MetaIoHandler<T, S>
source§impl<T: Metadata> Default for MetaIoHandler<T>
impl<T: Metadata> Default for MetaIoHandler<T>
source§impl<'a, T: Metadata, S: Middleware<T>> IntoIterator for &'a MetaIoHandler<T, S>
impl<'a, T: Metadata, S: Middleware<T>> IntoIterator for &'a MetaIoHandler<T, S>
source§impl<T: Metadata, S: Middleware<T>> IntoIterator for MetaIoHandler<T, S>
impl<T: Metadata, S: Middleware<T>> IntoIterator for MetaIoHandler<T, S>
source§impl<M: Metadata, S2: Middleware<M>> IoHandlerExtension<M> for MetaIoHandler<M, S2>
impl<M: Metadata, S2: Middleware<M>> IoHandlerExtension<M> for MetaIoHandler<M, S2>
source§fn augment<S: Middleware<M>>(self, handler: &mut MetaIoHandler<M, S>)
fn augment<S: Middleware<M>>(self, handler: &mut MetaIoHandler<M, S>)
handler
with additional methods.