Skip to main content

PendingEvents

Struct PendingEvents 

Source
pub struct PendingEvents<T, E> { /* private fields */ }
Expand description

The events waiting to be delivered to an observer.

A termination is the last event of a stream, so it is queued last and nothing is queued after it. Queuing anything after it gives the event back instead of accepting it: the caller drops it outside of the lock that guards this queue, because dropping a value can run arbitrary code that re-enters that lock.

Implementations§

Source§

impl<T, E> PendingEvents<T, E>

Source

pub fn new() -> Self

Source

pub fn with_capacity(capacity: usize) -> Self

Source

pub fn from_batch(events: EventBatch<T, E>) -> (Option<T>, Self)

Splits events into the value to deliver first and the queue holding what follows it.

The queue is built here, so it is never already terminated and nothing can be given back. The first value is handed to the caller instead of being queued, so a batch carrying a single value leaves the queue empty and never allocates it.

Source

pub fn is_terminated(&self) -> bool

Returns whether the last event has been queued, after which nothing can be queued anymore.

Source

pub fn is_empty(&self) -> bool

Returns whether there is nothing left to deliver.

Source

pub fn push(&mut self, event: Event<T, E>) -> Option<Event<T, E>>

Queues event, or gives it back when the last event has already been queued.

Source

pub fn push_batch( &mut self, events: EventBatch<T, E>, ) -> Option<EventBatch<T, E>>

Queues events, or gives them back when the last event has already been queued.

A batch is queued as a whole: it holds at most one termination and queues it last, so no event of a batch can be rejected on its own.

Source

pub fn pop(&mut self) -> Option<Event<T, E>>

Takes the next event to deliver, which is the termination once no value is left.

Source

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

Takes the next value to deliver, leaving the termination in place.

Source

pub fn take_termination(&mut self) -> Option<Termination<E>>

Takes the last event, whether or not values are still queued before it.

Trait Implementations§

Source§

impl<T, E> Debug for PendingEvents<T, E>

Source§

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

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

impl<T, E> Default for PendingEvents<T, E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

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

§

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

§

impl<T, E> Send for PendingEvents<T, E>

§

impl<T, E> Sync for PendingEvents<T, E>

§

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

§

impl<T, E> UnsafeUnpin for PendingEvents<T, E>

§

impl<T, E> UnwindSafe for PendingEvents<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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.