Skip to main content

LoadOptions

Struct LoadOptions 

Source
pub struct LoadOptions {
    pub children: Map<String, Value>,
    pub max_steps: usize,
    pub max_timers: usize,
    pub observe_system_emitted: bool,
    pub host_actions: HostActions,
}
Expand description

The options a machine is loaded with (JSON, all optional), which every actor started or restored from it shares, so a restore needs only the snapshot:

{ "children": { "<src>": MachineJSON }, // child machines for `invoke.src` (generic hosts)
  "maxSteps": number,                   // bound on work per call (default DEFAULT_MAX_STEPS, 10000)
  "maxTimers": number,                  // timers a time input fires at most in a chunk of control inputs alone (default 1000)
  "observeSystemEmitted": bool,         // every actor's emitted events, from the start or restore
  "hostActions": true | [string] }      // custom actions left to the host (generic hosts)

maxTimers is the workflow contract’s run option (Actor::set_max_timers): every actor started or restored from the machine takes it, so a run and its restore fire the same timers.

Fields§

§children: Map<String, Value>§max_steps: usize§max_timers: usize§observe_system_emitted: bool§host_actions: HostActions

true is HostActions::Unimplemented: a generic host binds every custom action to the host’s action implementation otherwise, so it binds none then, and every custom action is the host’s. A list is HostActions::Named; false or null is HostActions::None.

Implementations§

Source§

impl LoadOptions

Source

pub fn parse(text: &str, generic: bool) -> Result<Self, String>

Parses load options from text (empty for none). generic says whether this host loads definitions at run time and so takes children and hostActions (a typed machine compiles its children and actions in); an option it does not take is an error.

Source

pub fn parse_contract(text: &str, generic: bool) -> Result<Self, ApplyError>

LoadOptions::parse as a host’s load reports it: options that do not parse are WORKFLOW_INVALID_INPUT.

Source

pub fn start<C, E>( &self, machine: Arc<Machine<C, E>>, start: StartOptions, now: u64, ) -> Result<Actor<C, E>, ApplyError>
where C: Serialize + DeserializeOwned + Clone + Send + Sync + 'static, E: EventType + Send + Sync,

Starts machine at now with these options and the start’s, taking the input rather than copying it, as the workflow contract starts a run: the root’s id is ROOT_ID unless the start names one, the actor takes maxTimers, and a start whose root fails, so the run has no state to go on from, is WORKFLOW_MACHINE_FAILED and no actor. A now past 2^53 - 1 (MAX_TIME), which JavaScript does not hold exactly, is WORKFLOW_INVALID_INPUT, as a time input past it is.

Source

pub fn start_json<C, E>( &self, machine: Arc<Machine<C, E>>, options: &str, now: u64, ) -> Result<Actor<C, E>, String>
where C: Serialize + DeserializeOwned + Clone + Send + Sync + 'static, E: EventType + Send + Sync,

LoadOptions::start of start options as JSON text (see StartOptions::parse); the error is apply_error_json text, options that do not parse WORKFLOW_INVALID_INPUT.

Source

pub fn restore<C, E>( &self, machine: Arc<Machine<C, E>>, snapshot: &Value, ) -> Result<Actor<C, E>, ApplyError>
where C: Serialize + DeserializeOwned + Clone + Send + Sync + 'static, E: EventType + Send + Sync,

Restores machine from snapshot with these options. A snapshot that does not restore is WORKFLOW_INVALID_SNAPSHOT, and no actor.

Source

pub fn restore_json<C, E>( &self, machine: Arc<Machine<C, E>>, snapshot: &str, ) -> Result<Actor<C, E>, String>
where C: Serialize + DeserializeOwned + Clone + Send + Sync + 'static, E: EventType + Send + Sync,

LoadOptions::restore of a snapshot as JSON text; the error is apply_error_json text, WORKFLOW_INVALID_SNAPSHOT also of text that is not JSON.

Trait Implementations§

Source§

impl Clone for LoadOptions

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 Debug for LoadOptions

Source§

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

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

impl Default for LoadOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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