Skip to main content

mirascript_vm/
run_options.rs

1use std::{rc::Rc, time::Duration};
2
3use crate::{RuntimeProviders, default_runtime_providers};
4
5/// Limits and injectable providers used for each Runtime execution.
6#[derive(Clone)]
7pub struct RunOptions {
8    /// Maximum wall-clock time allowed for one execution.
9    pub timeout: Duration,
10    /// Number of interpreter checkpoints between timeout-provider checks.
11    pub checkpoint_interval: u32,
12    /// Maximum nested script and native call depth.
13    pub max_call_depth: u32,
14    /// Maximum number of elements created by bounded array operations.
15    pub max_array_len: usize,
16    /// Host implementation for random numbers, time, and debug output.
17    pub providers: Rc<dyn RuntimeProviders>,
18}
19
20impl Default for RunOptions {
21    fn default() -> Self {
22        Self {
23            timeout: Duration::from_millis(100),
24            checkpoint_interval: 100,
25            max_call_depth: 128,
26            max_array_len: 0x100_0000,
27            providers: default_runtime_providers(),
28        }
29    }
30}