Skip to main content

SubscriptionContext

Struct SubscriptionContext 

Source
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>

Source

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,

Source

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.

Source

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.

Source

pub fn send_next(&self, value: T) -> Flow

Sends value downstream. Returns the flow of the delivery, as Self::send does.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T, E, OR, M, D: Disposable> Clone for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, E, OR, M, D: Disposable> Debug for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, E, OR, M, D> Freeze for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: Freeze,

§

impl<T, E, OR, M, D> RefUnwindSafe for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: RefUnwindSafe,

§

impl<T, E, OR, M, D> Send for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: Send,

§

impl<T, E, OR, M, D> Sync for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: Sync,

§

impl<T, E, OR, M, D> Unpin for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: Unpin,

§

impl<T, E, OR, M, D> UnsafeUnpin for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: UnsafeUnpin,

§

impl<T, E, OR, M, D> UnwindSafe for SubscriptionContext<T, E, OR, M, D>
where SerializedDelivery<T, E, OR, ContextResources<M, D>>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.