Skip to main content

Control

Enum Control 

Source
pub enum Control<D = Value> {
    Time {
        now: i64,
        extra: Map<String, Value>,
    },
    Work {
        id: String,
        outcome: Outcome,
        data: Option<D>,
        extra: Map<String, Value>,
    },
}
Expand description

A control input: time, or the result of work. It has a kind, and never a type, so no event of a machine is one, whatever its type.

D is what a result of work carries, any JSON by default. A key the protocol does not read is kept in extra and written back after the keys it reads, so a rejected batch or a journal’s chunk holds the input as it was written.

Variants§

§

Time

{ "kind": "time", "now" }: moves the run’s clock towards now, in whole milliseconds, a safe integer of JavaScript, and fires each timer due by then. A now behind the run’s clock leaves it where it is.

Fields

§now: i64

The time to move to, in milliseconds.

§extra: Map<String, Value>

The keys of the input the protocol does not read, in order.

§

Work

{ "kind": "work", "id", "outcome", "data"? }: settles work the run waits for, by its id. data is Some of a null the input carries, and None of none; a result of done carries none.

Fields

§id: String

The work’s id, as the snapshot’s work lists it.

§outcome: Outcome

How the work ended.

§data: Option<D>

What invoked work gave, or why it failed.

§extra: Map<String, Value>

The keys of the input the protocol does not read, in order.

Implementations§

Source§

impl<D> Control<D>

Source

pub fn time(now: i64) -> Self

The time input that moves the clock towards now.

Source

pub fn resolved(id: impl Into<String>, data: D) -> Self

The result of invoked work id that gave data.

Source

pub fn rejected(id: impl Into<String>, error: D) -> Self

The result of invoked work id that failed with error.

Source

pub fn done(id: impl Into<String>) -> Self

The result of host action id, which the host did.

Trait Implementations§

Source§

impl<D: Clone> Clone for Control<D>

Source§

fn clone(&self) -> Self

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<D: Debug> Debug for Control<D>

Source§

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

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

impl<'de, D: DeserializeOwned> Deserialize<'de> for Control<D>

Source§

fn deserialize<De: Deserializer<'de>>( deserializer: De, ) -> Result<Self, De::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Ev, D> From<Control<D>> for Input<Ev, D>

Source§

fn from(control: Control<D>) -> Self

Converts to this type from the input type.
Source§

impl<D: PartialEq> PartialEq for Control<D>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<D: Serialize> Serialize for Control<D>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<D: PartialEq> StructuralPartialEq for Control<D>

Auto Trait Implementations§

§

impl<D> Forget for Control<D>

§

impl<D> Freeze for Control<D>

§

impl<D> Move for Control<D>

§

impl<D> RefUnwindSafe for Control<D>
where D: RefUnwindSafe,

§

impl<D> Send for Control<D>
where D: Send, RawTable<usize>: Send, RawVecInner: Send,

§

impl<D> Sync for Control<D>
where D: Sync, RawTable<usize>: Sync, RawVecInner: Sync,

§

impl<D> Unpin for Control<D>
where D: Unpin, *const u8 is !null: Unpin,

§

impl<D> UnsafeUnpin for Control<D>

§

impl<D> UnwindSafe for Control<D>
where NonNull<u8>: UnwindSafe, RawVecInner: UnwindSafe, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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.