pub struct Peer { /* private fields */ }Expand description
One end of a connection. Cheap to clone; all clones share the connection.
Implementations§
Source§impl Peer
impl Peer
Sourcepub async fn request<R: Request>(
&self,
params: &R::Params,
) -> Result<R::Result, Error>
pub async fn request<R: Request>( &self, params: &R::Params, ) -> Result<R::Result, Error>
Sends request R and waits for its result.
Sourcepub async fn call<P, T>(&self, method: &str, params: &P) -> Result<T, Error>
pub async fn call<P, T>(&self, method: &str, params: &P) -> Result<T, Error>
Sends a request by method name and waits for its result.
If the returned future is dropped before the response arrives, or
Options::request_timeout passes, $/cancel is sent for it.
Sourcepub async fn notify<N: Notification>(
&self,
params: &N::Params,
) -> Result<(), Error>
pub async fn notify<N: Notification>( &self, params: &N::Params, ) -> Result<(), Error>
Sends notification N.
Sourcepub async fn notify_raw<P: Serialize + ?Sized>(
&self,
method: &str,
params: &P,
) -> Result<(), Error>
pub async fn notify_raw<P: Serialize + ?Sized>( &self, method: &str, params: &P, ) -> Result<(), Error>
Sends a notification by method name.
Sourcepub fn close(&self)
pub fn close(&self)
Asks the connection to stop reading and shut down gracefully. In-flight
incoming requests still finish and are answered; outgoing requests
still waiting fail with Error::Closed.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Peer
impl Freeze for Peer
impl Move for Peer
impl RefUnwindSafe for Peer
impl Send for Peer
impl Sync for Peer
impl Unpin for Peer
impl UnsafeUnpin for Peer
impl UnwindSafe for Peer
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