[−][src]Trait xi_rpc::Peer
The Peer
trait represents the interface for the other side of the RPC
channel. It is intended to be used behind a pointer, a trait object.
Required methods
fn box_clone(&self) -> Box<dyn Peer>
Used to implement clone
in an object-safe way.
For an explanation on this approach, see
this thread.
fn send_rpc_notification(&self, method: &str, params: &Value)
Sends a notification (asynchronous RPC) to the peer.
fn send_rpc_request_async(
&self,
method: &str,
params: &Value,
f: Box<dyn Callback>
)
&self,
method: &str,
params: &Value,
f: Box<dyn Callback>
)
Sends a request asynchronously, and the supplied callback will be called when the response arrives.
Callback
is an alias for FnOnce(Result<Value, Error>)
; it must
be boxed because trait objects cannot use generic paramaters.
fn send_rpc_request(&self, method: &str, params: &Value) -> Result<Value, Error>
Sends a request (synchronous RPC) to the peer, and waits for the result.
fn request_is_pending(&self) -> bool
Determines whether an incoming request (or notification) is pending. This is intended to reduce latency for bulk operations done in the background.
fn schedule_idle(&self, token: usize)
Adds a token to the idle queue. When the runloop is idle and the
queue is not empty, the handler's idle
fn will be called
with the earliest added token.
fn schedule_timer(&self, after: Instant, token: usize)
Like schedule_idle
, with the guarantee that the handler's idle
fn will not be called before the provided Instant
.
Note
This is not intended as a high-fidelity timer. Regular RPC messages will always take priority over an idle task.
Implementors
impl Peer for DummyPeer
[src]
fn box_clone(&self) -> Box<dyn Peer>
[src]
fn send_rpc_notification(&self, _method: &str, _params: &Value)
[src]
fn send_rpc_request_async(
&self,
_method: &str,
_params: &Value,
f: Box<dyn Callback>
)
[src]
&self,
_method: &str,
_params: &Value,
f: Box<dyn Callback>
)
fn send_rpc_request(
&self,
_method: &str,
_params: &Value
) -> Result<Value, Error>
[src]
&self,
_method: &str,
_params: &Value
) -> Result<Value, Error>
fn request_is_pending(&self) -> bool
[src]
fn schedule_idle(&self, _token: usize)
[src]
fn schedule_timer(&self, _time: Instant, _token: usize)
[src]
impl<W: Write + Send + 'static> Peer for RawPeer<W>
[src]
fn box_clone(&self) -> Box<dyn Peer>
[src]
fn send_rpc_notification(&self, method: &str, params: &Value)
[src]
fn send_rpc_request_async(
&self,
method: &str,
params: &Value,
f: Box<dyn Callback>
)
[src]
&self,
method: &str,
params: &Value,
f: Box<dyn Callback>
)