1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2pub enum Fuel {
3 PerCall(u64),
4 PerTick(u64),
5}
6
7impl Fuel {
8 pub fn budget(self) -> u64 {
9 match self {
10 Self::PerCall(n) | Self::PerTick(n) => n,
11 }
12 }
13}
14
15#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16pub struct LogLimits {
17 pub lines_per_tick: u32,
18 pub line_bytes: usize,
19}
20
21impl Default for LogLimits {
22 fn default() -> Self {
23 Self {
24 lines_per_tick: 16,
25 line_bytes: 256,
26 }
27 }
28}
29
30#[derive(Clone, Copy, Debug, PartialEq, Eq)]
31pub struct Limits {
32 pub fuel: Fuel,
33 pub memory_bytes: usize,
34 pub table_elements: usize,
35 pub instances: usize,
36 pub tables: usize,
37 pub memories: usize,
38 pub stack_bytes: usize,
39 pub depth: u32,
40 pub component_bytes: usize,
41 pub manifest_bytes: usize,
42 pub log: Option<LogLimits>,
43}
44
45impl Default for Limits {
46 fn default() -> Self {
47 Self {
48 fuel: Fuel::PerCall(10_000_000),
49 memory_bytes: 64 << 20,
50 table_elements: 10_000,
51 instances: 32,
52 tables: 16,
53 memories: 4,
54 stack_bytes: 512 << 10,
55 depth: 1_000,
56 component_bytes: 16 << 20,
57 manifest_bytes: 16 << 10,
58 log: None,
59 }
60 }
61}