#[non_exhaustive]pub struct Options {
pub timeout: Option<Duration>,
pub max_depth: Option<usize>,
pub now: Option<i64>,
pub seed: Option<u64>,
pub cancel_token: Option<CancelToken>,
pub max_string_length: Option<usize>,
pub max_array_length: Option<usize>,
pub max_result_size: Option<usize>,
}Expand description
Evaluation guardrails, and the clock and seed that make an evaluation reproducible.
The struct is #[non_exhaustive], so new options can be added without breaking callers:
start from Options::new (or Options::default()) and chain the builder methods.
use jlens_core::Options;
use std::time::Duration;
let options = Options::new()
.timeout(Duration::from_millis(100))
.max_depth(500);
assert_eq!(options.max_depth, Some(500));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.timeout: Option<Duration>Maximum wall-clock time for one evaluation. Exceeding it raises D1012.
max_depth: Option<usize>Maximum evaluation depth (default 50,000; 500 on WebAssembly). Exceeding it raises
D1011.
now: Option<i64>The evaluation’s timestamp, in milliseconds since the epoch, for $now() and
$millis(). Default: the system clock, read once, the first time the evaluation needs
it.
seed: Option<u64>Seed for $random() and $shuffle(). Default: one taken from the system clock.
cancel_token: Option<CancelToken>Stops the evaluation with U1003 once the token is cancelled, from any thread.
max_string_length: Option<usize>Maximum length, in bytes of UTF-8, of a string that the evaluation builds (default
268,435,456: 256 MiB). Exceeding it raises U1001.
max_array_length: Option<usize>Maximum number of items in an array or sequence that the evaluation builds (default
16,777,216). Exceeding it raises U1001.
max_result_size: Option<usize>Maximum size of the result as compact JSON text, in bytes (default 268,435,456:
256 MiB), which also limits the arguments of a host function. A value that appears
several times counts each time, as it does in the text. Exceeding it raises U1001.
Implementations§
Source§impl Options
impl Options
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates options with no timeout, the default depth and size limits, the system clock and an unseeded generator.
Sourcepub fn now(self, millis: i64) -> Self
pub fn now(self, millis: i64) -> Self
Fixes the evaluation’s timestamp ($now(), $millis()), in milliseconds since the
epoch.
Sourcepub fn seed(self, seed: u64) -> Self
pub fn seed(self, seed: u64) -> Self
Seeds $random() and $shuffle(): the same seed gives the same sequence.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets the maximum wall-clock time for one evaluation (D1012 when exceeded).
Sourcepub fn max_depth(self, max_depth: usize) -> Self
pub fn max_depth(self, max_depth: usize) -> Self
Sets the maximum evaluation depth (D1011 when exceeded).
Sourcepub fn max_string_length(self, bytes: usize) -> Self
pub fn max_string_length(self, bytes: usize) -> Self
Sets the maximum length, in bytes, of a string the evaluation builds (U1001 when
exceeded).
Sourcepub fn max_array_length(self, items: usize) -> Self
pub fn max_array_length(self, items: usize) -> Self
Sets the maximum number of items of an array the evaluation builds (U1001 when
exceeded).
Sourcepub fn max_result_size(self, bytes: usize) -> Self
pub fn max_result_size(self, bytes: usize) -> Self
Sets the maximum size, in bytes of compact JSON text, of the result and of the
arguments of a host function (U1001 when exceeded).
Sourcepub fn cancel_token(self, token: CancelToken) -> Self
pub fn cancel_token(self, token: CancelToken) -> Self
Lets token stop the evaluation (U1003 once it is cancelled).