pub struct RawPeer<W: Write + 'static>(/* private fields */);
Expand description
An interface to access the other side of the RPC channel. The main purpose is to send RPC requests and notifications to the peer.
A single shared RawPeer
exists for each RpcLoop
; a reference can
be taken with RpcLoop::get_peer()
.
In general, RawPeer
shouldn’t be used directly, but behind a pointer as
the Peer
trait object.
Trait Implementations§
Source§impl<W: Write + Send + 'static> Peer for RawPeer<W>
impl<W: Write + Send + 'static> Peer for RawPeer<W>
Source§fn box_clone(&self) -> Box<dyn Peer>
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.Source§fn send_rpc_notification(&self, method: &str, params: &Value)
fn send_rpc_notification(&self, method: &str, params: &Value)
Sends a notification (asynchronous RPC) to the peer.
Source§fn send_rpc_request_async(
&self,
method: &str,
params: &Value,
f: Box<dyn Callback>,
)
fn send_rpc_request_async( &self, method: &str, params: &Value, f: Box<dyn Callback>, )
Sends a request asynchronously, and the supplied callback will
be called when the response arrives. Read more
Source§fn send_rpc_request(&self, method: &str, params: &Value) -> Result<Value, Error>
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.
Source§fn request_is_pending(&self) -> bool
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.
Source§fn schedule_idle(&self, token: usize)
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.Auto Trait Implementations§
impl<W> Freeze for RawPeer<W>
impl<W> RefUnwindSafe for RawPeer<W>
impl<W> Send for RawPeer<W>where
W: Send,
impl<W> Sync for RawPeer<W>where
W: Send,
impl<W> Unpin for RawPeer<W>
impl<W> UnwindSafe for RawPeer<W>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more