Struct jsonrpc_core::IoHandler

source ·
pub struct IoHandler<M: Metadata = ()>(/* private fields */);
Expand description

Simplified IoHandler with no Metadata associated with each request.

Implementations§

source§

impl IoHandler

source

pub fn new() -> Self

Creates new IoHandler without any metadata.

source

pub fn with_compatibility(compatibility: Compatibility) -> Self

Creates new IoHandler without any metadata compatible with specified protocol version.

source§

impl<M: Metadata + Default> IoHandler<M>

source

pub fn handle_request( &self, request: &str ) -> FutureResult<FutureResponse, FutureOutput>

Handle given string request asynchronously.

source

pub fn handle_rpc_request( &self, request: Request ) -> FutureRpcResult<FutureResponse, FutureOutput>

Handle deserialized RPC request asynchronously.

source

pub fn handle_call( &self, call: Call ) -> Either<FutureOutput, Either<FutureOutput, Ready<Option<Output>>>>

Handle single Call asynchronously.

source

pub fn handle_request_sync(&self, request: &str) -> 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.

Methods from Deref<Target = MetaIoHandler<M>>§

source

pub fn add_alias(&mut self, alias: &str, other: &str)

Adds an alias to a method.

source

pub fn add_sync_method<F>(&mut self, name: &str, method: F)where F: RpcMethodSync,

Adds new supported synchronous method.

A backward-compatible wrapper.

source

pub fn add_method<F>(&mut self, name: &str, method: F)where F: RpcMethodSimple,

Adds new supported asynchronous method.

source

pub fn add_notification<F>(&mut self, name: &str, notification: F)where F: RpcNotificationSimple,

Adds new supported notification

source

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.

source

pub fn add_notification_with_meta<F>(&mut self, name: &str, notification: F)where F: RpcNotification<T>,

Adds new supported notification with metadata support.

source

pub fn extend_with<F>(&mut self, methods: F)where F: IntoIterator<Item = (String, RemoteProcedure<T>)>,

Extend this MetaIoHandler with methods defined elsewhere.

source

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.

source

pub fn handle_request( &self, request: &str, meta: T ) -> FutureResult<S::Future, S::CallFuture>

Handle given request asynchronously.

source

pub fn handle_rpc_request( &self, request: Request, meta: T ) -> FutureRpcResult<S::Future, S::CallFuture>

Handle deserialized RPC request.

source

pub fn handle_call( &self, call: Call, meta: T ) -> Either<S::CallFuture, Either<FutureOutput, Ready<Option<Output>>>>

Handle single call asynchronously.

source

pub fn iter(&self) -> impl Iterator<Item = (&String, &RemoteProcedure<T>)>

Returns an iterator visiting all methods in arbitrary order.

Trait Implementations§

source§

impl<M: Clone + Metadata> Clone for IoHandler<M>

source§

fn clone(&self) -> IoHandler<M>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<M: Debug + Metadata> Debug for IoHandler<M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<M: Default + Metadata> Default for IoHandler<M>

source§

fn default() -> IoHandler<M>

Returns the “default value” for a type. Read more
source§

impl<M: Metadata> Deref for IoHandler<M>

§

type Target = MetaIoHandler<M>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<M: Metadata> DerefMut for IoHandler<M>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl From<IoHandler> for MetaIoHandler<()>

source§

fn from(io: IoHandler) -> Self

Converts to this type from the input type.
source§

impl<T: Metadata> IntoIterator for IoHandler<T>

§

type Item = <MetaIoHandler<T> as IntoIterator>::Item

The type of the elements being iterated over.
§

type IntoIter = <MetaIoHandler<T> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<M: Metadata> IoHandlerExtension<M> for IoHandler<M>

source§

fn augment<S: Middleware<M>>(self, handler: &mut MetaIoHandler<M, S>)

Extend given handler with additional methods.

Auto Trait Implementations§

§

impl<M = ()> !RefUnwindSafe for IoHandler<M>

§

impl<M> Send for IoHandler<M>

§

impl<M> Sync for IoHandler<M>

§

impl<M> Unpin for IoHandler<M>

§

impl<M = ()> !UnwindSafe for IoHandler<M>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.