Skip to main content

SerializedDelivery

Struct SerializedDelivery 

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

Source

pub fn idle(observer: OR, resources: R) -> Self

Starts with the observer attached and parked, waiting for the first event.

Source

pub fn stop(&self)

Stops the delivery, dropping the observer without notifying it. Stopping again is a no-op.

Source

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

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T, E, OR, R> Clone for SerializedDelivery<T, E, OR, R>
where Shared<Mutable<State<T, E, OR, R>>>: 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, R> Debug for SerializedDelivery<T, E, OR, R>
where Shared<Mutable<State<T, E, OR, R>>>: 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, R> Freeze for SerializedDelivery<T, E, OR, R>
where Arc<Mutex<State<T, E, OR, R>>>: Freeze,

§

impl<T, E, OR, R> RefUnwindSafe for SerializedDelivery<T, E, OR, R>
where Arc<Mutex<State<T, E, OR, R>>>: RefUnwindSafe,

§

impl<T, E, OR, R> Send for SerializedDelivery<T, E, OR, R>
where Arc<Mutex<State<T, E, OR, R>>>: Send,

§

impl<T, E, OR, R> Sync for SerializedDelivery<T, E, OR, R>
where Arc<Mutex<State<T, E, OR, R>>>: Sync,

§

impl<T, E, OR, R> Unpin for SerializedDelivery<T, E, OR, R>
where Arc<Mutex<State<T, E, OR, R>>>: Unpin,

§

impl<T, E, OR, R> UnsafeUnpin for SerializedDelivery<T, E, OR, R>
where Arc<Mutex<State<T, E, OR, R>>>: UnsafeUnpin,

§

impl<T, E, OR, R> UnwindSafe for SerializedDelivery<T, E, OR, R>
where Arc<Mutex<State<T, E, OR, R>>>: 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.