Struct rpc_it::rpc::Sender

source ·
pub struct Sender(_);
Expand description

Send-only handle. This holds strong reference to the connection.

Implementations§

source§

impl Sender

source

pub async fn call<R: DeserializeOwned>( &self, method: &str, params: &impl Serialize ) -> Result<R, CallError>

A shortcut for request, flush, and receive response.

source

pub async fn call_with_err<R: DeserializeOwned, E: DeserializeOwned>( &self, method: &str, params: &impl Serialize ) -> Result<R, TypedCallError<E>>

A shortcut for strictly typed request

source

pub async fn request<T: Serialize>( &self, method: &str, params: &T ) -> Result<ResponseFuture<'_>, SendError>

Send request, and create response future which will be resolved when the response is received.

source

pub async fn notify<T: Serialize>( &self, method: &str, params: &T ) -> Result<(), SendError>

Send notification message.

source

pub fn request_deferred<T: Serialize>( &self, method: &str, params: &T ) -> Result<ResponseFuture<'_>, SendError>

Sends a request and returns a future that will be resolved when the response is received.

This method is non-blocking, as the message writing will be deferred to the background

source

pub fn notify_deferred<T: Serialize>( &self, method: &str, params: &T ) -> Result<(), SendError>

Send deferred notification. This method is non-blocking, as the message writing will be deferred to the background driver worker.

source

pub fn is_disconnected(&self) -> bool

Check if the connection is disconnected.

source

pub fn close(self) -> bool

Closes the connection. If it’s already closed, it’ll return false.

Caution

If multiple threads calls this method at the same time, more than one thread may return true, as the close operation is lazy.

source

pub async fn flush(&self) -> Result<()>

Flush underlying write stream.

source

pub fn is_request_enabled(&self) -> bool

Is sending request enabled?

source

pub fn get_feature_flags(&self) -> Feature

Get feature flags

Trait Implementations§

source§

impl Clone for Sender

source§

fn clone(&self) -> Sender

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 Debug for Sender

source§

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

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

impl From<Transceiver> for Sender

source§

fn from(value: Transceiver) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Sender

§

impl Send for Sender

§

impl Sync for Sender

§

impl Unpin for Sender

§

impl !UnwindSafe for Sender

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.