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>
impl<T, E> PendingEvents<T, E>
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn from_batch(events: EventBatch<T, E>) -> (Option<T>, Self)
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.
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Returns whether the last event has been queued, after which nothing can be queued anymore.
Sourcepub fn push(&mut self, event: Event<T, E>) -> Option<Event<T, E>>
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.
Sourcepub fn push_batch(
&mut self,
events: EventBatch<T, E>,
) -> Option<EventBatch<T, E>>
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.
Sourcepub fn pop(&mut self) -> Option<Event<T, E>>
pub fn pop(&mut self) -> Option<Event<T, E>>
Takes the next event to deliver, which is the termination once no value is left.
Sourcepub fn pop_next(&mut self) -> Option<T>
pub fn pop_next(&mut self) -> Option<T>
Takes the next value to deliver, leaving the termination in place.
Sourcepub fn take_termination(&mut self) -> Option<Termination<E>>
pub fn take_termination(&mut self) -> Option<Termination<E>>
Takes the last event, whether or not values are still queued before it.