scratch_test_interpreter/builder/
limits.rs1#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Clone, Hash)]
2pub struct Limits {
3 max_string_length: Option<usize>,
4 max_executed_stmts: Option<usize>,
5 max_statement_stack_height: Option<usize>,
6}
7
8#[allow(unused)]
9impl Limits {
10 pub const RESTRICTIVE: Limits = Limits {
11 max_statement_stack_height: Some(100),
12 max_string_length: Some(1024),
13 max_executed_stmts: Some(10 * 1024),
14 };
15 pub const fn new() -> Self {
16 Self {
17 max_string_length: None,
18 max_executed_stmts: None,
19 max_statement_stack_height: None,
20 }
21 }
22
23 pub const fn max_string_length(&self) -> &Option<usize> {
24 &self.max_string_length
25 }
26 pub const fn max_executed_stmts(&self) -> &Option<usize> {
27 &self.max_executed_stmts
28 }
29 pub const fn max_statement_stack_height(&self) -> &Option<usize> {
30 &self.max_statement_stack_height
31 }
32
33 pub const fn set_max_string_length(&mut self, len: Option<usize>) -> &mut Self {
34 self.max_string_length = len;
35 self
36 }
37 pub const fn set_max_statement_stack_height(&mut self, v: Option<usize>) -> &mut Self {
38 self.max_statement_stack_height = v;
39 self
40 }
41 pub const fn set_max_executed_stmts(&mut self, v: Option<usize>) -> &mut Self {
42 self.max_executed_stmts = v;
43 self
44 }
45
46 pub const fn with_max_string_length(mut self, len: Option<usize>) -> Self {
47 self.set_max_string_length(len);
48 self
49 }
50 pub const fn with_max_statement_stack_height(mut self, v: Option<usize>) -> Self {
51 self.set_max_statement_stack_height(v);
52 self
53 }
54 pub const fn with_max_executed_stmts(mut self, v: Option<usize>) -> Self {
55 self.set_max_executed_stmts(v);
56 self
57 }
58}