#[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
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: u32The 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: StringThe label to start from. module.label (for a program with one module, just the label name also works).
max_value_bytes: usizeThe 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: usizeThe 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: u64The 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: LoadPolicyHow 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
impl VmConfig
Sourcepub fn load_policy(self, policy: LoadPolicy) -> Self
pub fn load_policy(self, policy: LoadPolicy) -> Self
Sets how loads treat variables whose type no longer matches the scripts.
Sourcepub fn max_value_bytes(self, bytes: usize) -> Self
pub fn max_value_bytes(self, bytes: usize) -> Self
Sets the maximum size of one value (bytes).
Sourcepub fn max_total_bytes(self, bytes: Option<usize>) -> Self
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).
Sourcepub fn start(self, label: &str) -> Self
pub fn start(self, label: &str) -> Self
Sets the label to start from (module.label; with one module, just the label name also works).
Sourcepub fn seen_points<I, S>(self, points: I) -> Self
pub fn seen_points<I, S>(self, points: I) -> Self
Sets the passed stop points (module.label#id; as returned by crate::vm::Vm::seen_points).
Sourcepub fn history_limit(self, limit: usize) -> Self
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).
Sourcepub fn persistent_data(self, bytes: Vec<u8>) -> Self
pub fn persistent_data(self, bytes: Vec<u8>) -> Self
Sets the persistent data (the bytes of crate::vm::Vm::save_persistent).
Sourcepub fn max_call_depth(self, depth: u32) -> Self
pub fn max_call_depth(self, depth: u32) -> Self
Sets the maximum depth of calls.
Sourcepub fn interrupt(self, handle: InterruptHandle) -> Self
pub fn interrupt(self, handle: InterruptHandle) -> Self
Sets the token that interrupts a run.
Sourcepub fn max_steps_per_run(self, steps: Option<u64>) -> Self
pub fn max_steps_per_run(self, steps: Option<u64>) -> Self
Sets the maximum number of instructions in one run.