jsonrpc_pubsub::oneshot

Struct Sender

Source
pub struct Sender<T> { /* private fields */ }
Expand description

A sender part of the channel.

Implementations§

Source§

impl<T> Sender<T>

Source

pub fn send(self, t: T) -> Result<(), T>

Consume the sender and queue up an item to send.

This method returns right away and never blocks, there is no guarantee though that the message is received by the other end.

Source

pub fn send_and_wait(self, t: T) -> impl Future<Output = Result<(), ()>>

Consume the sender and send an item.

The returned future will resolve when the message is received on the other end. Note that polling the future is actually not required to send the message as that happens synchronously. The future resolves to error in case the receiving end was dropped before being able to process the message.

Methods from Deref<Target = Sender<T>>§

Source

pub fn poll_canceled(&mut self, cx: &mut Context<'_>) -> Poll<()>

Polls this Sender half to detect whether its associated Receiver has been dropped.

§Return values

If Ready(()) is returned then the associated Receiver has been dropped, which means any work required for sending should be canceled.

If Pending is returned then the associated Receiver is still alive and may be able to receive a message if sent. The current task, however, is scheduled to receive a notification if the corresponding Receiver goes away.

Source

pub fn cancellation(&mut self) -> Cancellation<'_, T>

Creates a future that resolves when this Sender’s corresponding Receiver half has hung up.

This is a utility wrapping poll_canceled to expose a Future.

Source

pub fn is_canceled(&self) -> bool

Tests to see whether this Sender’s corresponding Receiver has been dropped.

Unlike poll_canceled, this function does not enqueue a task for wakeup upon cancellation, but merely reports the current state, which may be subject to concurrent modification.

Source

pub fn is_connected_to(&self, receiver: &Receiver<T>) -> bool

Tests to see whether this Sender is connected to the given Receiver. That is, whether they were created by the same call to channel.

Trait Implementations§

Source§

impl<T: Debug> Debug for Sender<T>

Source§

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

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

impl<T> DerefMut for Sender<T>

Source§

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

Mutably dereferences the value.
Source§

impl<T> Deref for Sender<T>

Source§

type Target = Sender<T>

The resulting type after dereferencing.
Source§

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

Dereferences the value.

Auto Trait Implementations§

§

impl<T> Freeze for Sender<T>

§

impl<T> !RefUnwindSafe for Sender<T>

§

impl<T> Send for Sender<T>
where T: Send,

§

impl<T> Sync for Sender<T>
where T: Send,

§

impl<T> Unpin for Sender<T>

§

impl<T> !UnwindSafe for Sender<T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V