pub struct SubscriptionContext<T, E, OR, M, D: Disposable = ()> { /* private fields */ }Expand description
Context used by operator observers to serialize model updates and downstream events.
D is the disposal of the source subscription the context owns, and () when it owns none.
Implementations§
Source§impl<T, E, OR, M, D: Disposable> SubscriptionContext<T, E, OR, M, D>
impl<T, E, OR, M, D: Disposable> SubscriptionContext<T, E, OR, M, D>
Sourcepub fn downgrade(&self) -> WeakSubscriptionContext<T, E, OR, M, D>
pub fn downgrade(&self) -> WeakSubscriptionContext<T, E, OR, M, D>
Creates a non-owning reference to this context.
Source§impl<T, E, OR, M, D> SubscriptionContext<T, E, OR, M, D>where
OR: Observer<T, E>,
D: Disposable,
impl<T, E, OR, M, D> SubscriptionContext<T, E, OR, M, D>where
OR: Observer<T, E>,
D: Disposable,
Sourcepub fn update<R, DO, const EVENTS_DECIDED: bool>(
&self,
callback: impl FnOnce(&mut M) -> UpdateOutcome<T, E, R, DO, EVENTS_DECIDED>,
) -> Result<R, DeliveryStopped>
pub fn update<R, DO, const EVENTS_DECIDED: bool>( &self, callback: impl FnOnce(&mut M) -> UpdateOutcome<T, E, R, DO, EVENTS_DECIDED>, ) -> Result<R, DeliveryStopped>
Updates the model and sends the events that update produced, while the context is locked.
An update that emits nothing simply decides no events, and then nothing is sent here.
The callback must not call external APIs or drop values that can re-enter this context.
Return such values through UpdateOutcome::with_drop_outside instead.
If the context’s delivery has stopped, the callback is not invoked and DeliveryStopped
is returned.
Sourcepub fn update_flow<DO, const EVENTS_DECIDED: bool>(
&self,
callback: impl FnOnce(&mut M) -> UpdateOutcome<T, E, (), DO, EVENTS_DECIDED>,
) -> Flow
pub fn update_flow<DO, const EVENTS_DECIDED: bool>( &self, callback: impl FnOnce(&mut M) -> UpdateOutcome<T, E, (), DO, EVENTS_DECIDED>, ) -> Flow
Self::update for an operator’s on_next, reporting the flow instead of a result.
The flow is what delivering the events the update produced answered, and Flow::Stop
when the context has stopped, so an operator observer can return it directly.
Sourcepub fn send_next(&self, value: T) -> Flow
pub fn send_next(&self, value: T) -> Flow
Sends value downstream. Returns the flow of the delivery, as Self::send does.
Sourcepub fn send_termination(&self, termination: Termination<E>)
pub fn send_termination(&self, termination: Termination<E>)
Sends termination downstream.
Nothing is answered: a termination is the last event, so the caller is done whether it
was delivered, queued behind a running delivery, or rejected by a context that had already
stopped — Self::send would say Flow::Stop in every case.
Sourcepub fn send(&self, events: EventBatch<T, E>) -> Flow
pub fn send(&self, events: EventBatch<T, E>) -> Flow
Sends events downstream, delivering them now or queueing them behind a running delivery.
Returns whether downstream still accepts events. Flow::Stop means the events were
rejected and dropped, because the context has stopped or a termination is already queued,
or that the stream is over: events carried a termination, or delivering them ended it.