pub struct SerializedDelivery<T, E, OR, R>(/* private fields */);Expand description
A shared, serialized delivery of events to one observer.
R is whatever the host owns alongside the observer. It is dropped, outside the lock, once the
delivery stops — after the terminal notification when the delivery stops by terminating.
Implementations§
Source§impl<T, E, OR, R> SerializedDelivery<T, E, OR, R>
impl<T, E, OR, R> SerializedDelivery<T, E, OR, R>
Sourcepub fn idle(observer: OR, resources: R) -> Self
pub fn idle(observer: OR, resources: R) -> Self
Starts with the observer attached and parked, waiting for the first event.
Sourcepub fn stop(&self)
pub fn stop(&self)
Stops the delivery, dropping the observer without notifying it. Stopping again is a no-op.
pub fn downgrade(&self) -> WeakSerializedDelivery<T, E, OR, R>
Source§impl<T, E, OR, R> SerializedDelivery<T, E, OR, R>where
OR: Observer<T, E>,
impl<T, E, OR, R> SerializedDelivery<T, E, OR, R>where
OR: Observer<T, E>,
Sourcepub fn send(&self, events: EventBatch<T, E>) -> Flow
pub fn send(&self, events: EventBatch<T, E>) -> Flow
Queues events and delivers whatever that makes deliverable.
Returns whether the observer still accepts events. It is Flow::Stop once the delivery
has stopped or a termination is already queued — the events are then rejected and dropped
outside the lock — and also whenever events carries a termination, since nothing can be
queued after it. Values queued behind a delivery running elsewhere are reported as
Flow::Continue, as Flow describes.
Sourcepub fn update<Out, DO, const EVENTS_DECIDED: bool>(
&self,
update: impl FnOnce(&mut R) -> UpdateOutcome<T, E, Out, DO, EVENTS_DECIDED>,
) -> Result<Out, DeliveryStopped>
pub fn update<Out, DO, const EVENTS_DECIDED: bool>( &self, update: impl FnOnce(&mut R) -> UpdateOutcome<T, E, Out, DO, EVENTS_DECIDED>, ) -> Result<Out, DeliveryStopped>
Updates the resources and queues the events that update produced, under one lock.
This is how a host changes what it owns, whether or not that emits anything: an update that emits nothing simply decides no events, and then no delivery can start here.
update describes its outcome with an UpdateOutcome. It must not notify anyone or drop
a value that can re-enter this delivery: it runs under the lock, so hand such a value to
UpdateOutcome::with_drop_outside instead.
Returns DeliveryStopped, without running update, once the delivery has stopped.
update and everything it captured are then dropped outside the lock.
Sourcepub fn update_with_flow<Out, DO, const EVENTS_DECIDED: bool>(
&self,
update: impl FnOnce(&mut R) -> UpdateOutcome<T, E, Out, DO, EVENTS_DECIDED>,
) -> Result<(Out, Flow), DeliveryStopped>
pub fn update_with_flow<Out, DO, const EVENTS_DECIDED: bool>( &self, update: impl FnOnce(&mut R) -> UpdateOutcome<T, E, Out, DO, EVENTS_DECIDED>, ) -> Result<(Out, Flow), DeliveryStopped>
Self::update, reporting as well whether the observer still accepts events.
The flow is what delivering the queued events answered, or Flow::Continue when the
update queued none. A stopped delivery answers DeliveryStopped rather than a flow, so a
host that only needs the flow maps that error to Flow::Stop.