Skip to main content

VmConfig

Struct VmConfig 

Source
#[non_exhaustive]
pub struct VmConfig { pub max_steps_per_run: Option<u64>, pub max_call_depth: u32, pub start: String, pub max_value_bytes: usize, pub max_total_bytes: Option<usize>, pub seen_points: Vec<String>, pub history_limit: usize, pub seed: u64, pub persistent: Option<Vec<u8>>, pub load_policy: LoadPolicy, pub interrupt: Option<InterruptHandle>, }
Expand description

VM settings.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§max_steps_per_run: Option<u64>

The number of instructions one run can execute. None means no limit.

§max_call_depth: u32

The maximum depth of calls in scripts. Label calls (call stack frames) and fn calls (including recursion) are counted together. Trying to go beyond this is a runtime error (CallDepthExceeded).

§start: String

The label to start from. module.label (for a program with one module, just the label name also works).

§max_value_bytes: usize

The maximum size of one value (bytes). For strings, the length; for list, struct, enum and Option, an estimate of the total of the contents (crate::value::Value::approx_bytes). Exceeding it is the runtime error ValueTooLarge.

§max_total_bytes: Option<usize>

The maximum total size (bytes; the estimate of crate::value::Value::approx_bytes) of values held in variables. Counts module variables, host-declared variables and local variables (including call stack frames and fn call frames). Exceeding it is the runtime error MemoryLimitExceeded. None means no limit. The default is 64 MiB.

§seen_points: Vec<String>

Passed stop points (module.label#id). Read by seen. Also used when rebuilding the arguments of a stop point on load, so it is part of the settings passed to Vm::load. To replace it later, use crate::vm::Vm::set_seen_points.

§history_limit: usize

The maximum number of entries kept in the history of stop points (crate::vm::Vm::history). The oldest are dropped. 0 means nothing is recorded. The default is 200.

§seed: u64

The seed of the random generator (random). The same seed, script and input give the same sequence. On load, the state of the random generator in the save is used (the seed is not).

§persistent: Option<Vec<u8>>

Persistent data (the bytes returned by crate::vm::Vm::save_persistent). If present, the values of persistent vars and the passed stop points are put in when creating (loading) the VM. Takes priority over seen_points (passed stop points are replaced by this). When rebuilding the arguments of a stop point on load, scripts that read persistent vars and seen get the same arguments as when saved. To pass it later, use crate::vm::Vm::load_persistent.

§load_policy: LoadPolicy

How loads treat variables whose type no longer matches the scripts. Applies to Vm::load, Vm::new with persistent and Vm::load_persistent. The default is LoadPolicy::Strict.

§interrupt: Option<InterruptHandle>

The token that interrupts a run from another thread (spec/host/01-execution.md, 1.9a). If None, the VM makes its own (get it with crate::vm::Vm::interrupt_handle). Pass one to share it between VMs.

Implementations§

Source§

impl VmConfig

Source

pub fn load_policy(self, policy: LoadPolicy) -> Self

Sets how loads treat variables whose type no longer matches the scripts.

Source

pub fn max_value_bytes(self, bytes: usize) -> Self

Sets the maximum size of one value (bytes).

Source

pub fn max_total_bytes(self, bytes: Option<usize>) -> Self

Sets the maximum total size of values held in variables (bytes; None means no limit).

Source

pub fn start(self, label: &str) -> Self

Sets the label to start from (module.label; with one module, just the label name also works).

Source

pub fn seen_points<I, S>(self, points: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Sets the passed stop points (module.label#id; as returned by crate::vm::Vm::seen_points).

Source

pub fn history_limit(self, limit: usize) -> Self

Sets the maximum number of entries in the history of stop points (0 means nothing is recorded).

Source

pub fn seed(self, seed: u64) -> Self

Sets the seed of the random generator.

Source

pub fn persistent_data(self, bytes: Vec<u8>) -> Self

Sets the persistent data (the bytes of crate::vm::Vm::save_persistent).

Source

pub fn max_call_depth(self, depth: u32) -> Self

Sets the maximum depth of calls.

Source

pub fn interrupt(self, handle: InterruptHandle) -> Self

Sets the token that interrupts a run.

Source

pub fn max_steps_per_run(self, steps: Option<u64>) -> Self

Sets the maximum number of instructions in one run.

Trait Implementations§

Source§

impl Clone for VmConfig

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 VmConfig

Source§

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

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

impl Default for VmConfig

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.