Struct TaskHandle

Source
pub struct TaskHandle<T, E: TError> {
    pub rx: Receiver<T>,
    pub ctx: Context<E>,
}

Fields§

§rx: Receiver<T>§ctx: Context<E>

Implementations§

Source§

impl<T, E: TError> TaskHandle<T, E>

Source

pub fn stop(self) -> FutureTaskState<E>

Source

pub fn wait_for_stopped(self) -> impl Future<Output = Result<(), TaskError<E>>>

Source

pub async fn recv(&mut self) -> Option<T>

Receives the next value for this receiver.

This method returns None if the channel has been closed and there are no remaining messages in the channel’s buffer. This indicates that no further values can ever be received from this Receiver. The channel is closed when all senders have been dropped, or when close is called.

If there are no messages in the channel’s buffer, but the channel has not yet been closed, this method will sleep until a message is sent or the channel is closed. Note that if close is called, but there are still outstanding Permits from before it was closed, the channel is not considered closed by recv until the permits are released.

§Cancel safety

This method is cancel safe. If recv is used as the event in a tokio::select! statement and some other branch completes first, it is guaranteed that no messages were received on this channel.

Source

pub fn blocking_recv(&mut self) -> Option<T>

Blocking receive to call outside of asynchronous contexts.

This method returns None if the channel has been closed and there are no remaining messages in the channel’s buffer. This indicates that no further values can ever be received from this Receiver. The channel is closed when all senders have been dropped, or when close is called.

If there are no messages in the channel’s buffer, but the channel has not yet been closed, this method will block until a message is sent or the channel is closed.

This method is intended for use cases where you are sending from asynchronous code to synchronous code, and will work even if the sender is not using blocking_send to send the message.

Note that if close is called, but there are still outstanding Permits from before it was closed, the channel is not considered closed by blocking_recv until the permits are released.

Auto Trait Implementations§

§

impl<T, E> Freeze for TaskHandle<T, E>

§

impl<T, E> RefUnwindSafe for TaskHandle<T, E>

§

impl<T, E> Send for TaskHandle<T, E>
where T: Send,

§

impl<T, E> Sync for TaskHandle<T, E>
where T: Send,

§

impl<T, E> Unpin for TaskHandle<T, E>

§

impl<T, E> UnwindSafe for TaskHandle<T, E>

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