Skip to main content

Effect

Enum Effect 

Source
pub enum Effect<M, I> {
    Send {
        to: NodeId,
        msg: M,
    },
    Indicate(I),
    SetTimer {
        after: Duration,
        id: TimerId,
    },
}
Expand description

Everything a protocol is able to do.

A protocol expresses every outward action as one of these. It does not transmit, deliver, or schedule by any other means — which is what allows the same protocol to run under a simulator and under a real driver without knowing the difference.

The two type parameters are the protocol’s own message and indication types. A timer needs none: it is named by an opaque TimerId, and the driver hands the expiry back to whoever registered it rather than deducing the owner from the token’s type.

Storage is not here: an effect is deferred, and a write must be durable before it returns. See crate::store.

Variants§

§

Send

Transmit msg to to. Best-effort: the layer below may lose it.

Fields

§msg: M
§

Indicate(I)

Raise an indication to the layer above — the protocol delivering on its guarantee.

§

SetTimer

Request that id be handed back after after has elapsed.

Fields

§after: Duration

Implementations§

Source§

impl<M, I> Effect<M, I>

Source

pub fn map<M2, I2>( self, msg: impl FnOnce(M) -> M2, ind: impl FnOnce(I) -> I2, ) -> Effect<M2, I2>

Rewrite this effect’s parts, for a parent translating a child’s effect into its own terms.

This is the composition primitive: a parent re-wraps rather than re-encodes, so a message crossing layers accumulates type structure but is never serialised twice. A timer passes through untouched, having nothing in it that belongs to one layer.

Trait Implementations§

Source§

impl<M: Clone, I: Clone> Clone for Effect<M, I>

Source§

fn clone(&self) -> Effect<M, I>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<M: Debug, I: Debug> Debug for Effect<M, I>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<M: Eq, I: Eq> Eq for Effect<M, I>

Source§

impl<M: PartialEq, I: PartialEq> PartialEq for Effect<M, I>

Source§

fn eq(&self, other: &Effect<M, I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<M: PartialEq, I: PartialEq> StructuralPartialEq for Effect<M, I>

Auto Trait Implementations§

§

impl<M, I> Freeze for Effect<M, I>
where M: Freeze, I: Freeze,

§

impl<M, I> RefUnwindSafe for Effect<M, I>

§

impl<M, I> Send for Effect<M, I>
where M: Send, I: Send,

§

impl<M, I> Sync for Effect<M, I>
where M: Sync, I: Sync,

§

impl<M, I> Unpin for Effect<M, I>
where M: Unpin, I: Unpin,

§

impl<M, I> UnsafeUnpin for Effect<M, I>
where M: UnsafeUnpin, I: UnsafeUnpin,

§

impl<M, I> UnwindSafe for Effect<M, I>
where M: UnwindSafe, I: 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V