Sender

Struct Sender 

Source
pub struct Sender<R: Deref<Target = State<Q, F, E>>, Q, F, E> { /* private fields */ }
Expand description

Allows sending data to the SPSC channel via its BulkConsumer implementation.

Implementations§

Source§

impl<R: Deref<Target = State<Q, F, E>>, Q: Queue, F, E> Sender<R, Q, F, E>

Source

pub fn len(&self) -> usize

Returns the number of items that are currently buffered.

Source

pub fn is_empty(&self) -> bool

Returns whether there are currently no items buffered.

Source

pub fn cause_error(&mut self, err: E)

Sets an error to be emitted on the corresponding Receiver. The error is only emitted there when trying to produce values via produce or expose_items (or any method calling one of these), but never when slurping or calling consider_produced.

Must not call any of the Consumer, BufferedConsumer, or BulkProducer methods on this Receiver after calling this function, nor close_sync. May call this function at most once per Receiver. Must not call this function after calling close or close_sync.

Source

pub fn close_sync(&mut self, fin: F)

Same as calling Consumer::close, but sync. Must not use this multiple times, after calling close, or after calling cause_error.

Source

pub fn is_receiver_dropped(&self) -> bool

Returns whether the correponding Receiver has been dropped already.

Trait Implementations§

Source§

impl<R: Deref<Target = State<Q, F, E>>, Q: Queue, F, E> BufferedConsumer for Sender<R, Q, F, E>

Source§

async fn flush(&mut self) -> Result<(), Self::Error>

Forces the consumer to perform any side-effects that were delayed for previously consumed items. Read more
Source§

impl<R: Deref<Target = State<Q, F, E>>, Q: Queue, F, E> BulkConsumer for Sender<R, Q, F, E>

Source§

async fn expose_slots<'a>( &'a mut self, ) -> Result<&'a mut [Self::Item], Self::Error>
where Self::Item: 'a,

A low-level method for consuming multiple items at a time. If you are only working with consumers (rather than implementing them), you will probably want to ignore this method and use BulkConsumer::bulk_consume instead. Read more
Source§

async fn consume_slots(&mut self, amount: usize) -> Result<(), Self::Error>

A low-level method for consuming multiple items at a time. If you are only working with consumers (rather than implementing them), you will probably want to ignore this method and use BulkConsumer::bulk_consume instead. Read more
Source§

fn bulk_consume( &mut self, buf: &[Self::Item], ) -> impl Future<Output = Result<usize, Self::Error>>
where Self::Item: Clone,

Consumes a non-zero number of items by reading them from a given buffer and returning how many items were consumed. Read more
Source§

fn bulk_consume_full_slice( &mut self, buf: &[Self::Item], ) -> impl Future<Output = Result<(), ConsumeAtLeastError<Self::Error>>>
where Self::Item: Clone,

Tries to bulk-consume (copies of) all items in the given slice. Reports an error if the slice could not be consumed completely. Read more
Source§

impl<R: Deref<Target = State<Q, F, E>>, Q: Queue, F, E> Consumer for Sender<R, Q, F, E>

Source§

async fn consume(&mut self, item_: Self::Item) -> Result<(), Self::Error>

Writes the item into the buffer queue, waiting for buffer space to become available (by reading items from the corresponding Sender) if necessary.

Source§

type Item = <Q as Queue>::Item

The sequence consumed by this consumer starts with arbitrarily many values of this type.
Source§

type Final = F

The sequence consumed by this consumer ends with up to one value of this type.
Source§

type Error = Infallible

The type of errors the consumer can emit instead of doing its job.
Source§

async fn close(&mut self, fin: Self::Final) -> Result<(), Self::Error>

Attempts to consume the final item. Read more
Source§

fn consume_full_slice( &mut self, buf: &[Self::Item], ) -> impl Future<Output = Result<(), ConsumeAtLeastError<Self::Error>>>
where Self::Item: Clone,

Tries to consume (clones of) all items in the given slice. Reports an error if the slice could not be consumed completely. Read more
Source§

impl<R: Debug + Deref<Target = State<Q, F, E>>, Q: Debug, F: Debug, E: Debug> Debug for Sender<R, Q, F, E>

Source§

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

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

impl<R: Deref<Target = State<Q, F, E>>, Q, F, E> Drop for Sender<R, Q, F, E>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<R, Q, F, E> Freeze for Sender<R, Q, F, E>
where R: Freeze,

§

impl<R, Q, F, E> RefUnwindSafe for Sender<R, Q, F, E>

§

impl<R, Q, F, E> Send for Sender<R, Q, F, E>
where R: Send, Q: Send, F: Send, E: Send,

§

impl<R, Q, F, E> Sync for Sender<R, Q, F, E>
where R: Sync, Q: Sync, F: Sync, E: Sync,

§

impl<R, Q, F, E> Unpin for Sender<R, Q, F, E>
where R: Unpin, Q: Unpin, F: Unpin, E: Unpin,

§

impl<R, Q, F, E> UnwindSafe for Sender<R, Q, F, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.