1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Runtime budgets and public byte-count value types.
//!
//! Parser limits, runtime input limits, execution limits, and trace snapshot limits are separate
//! domains. Parser limits bound source ingestion and parsed program size;
//! runtime input limits bind raw input validation; execution limits decide
//! whether execution may allocate or continue; trace snapshot limits decide
//! whether a borrowed trace event may be materialized as owned bytes. Count
//! types report measured lengths without erasing those domains into plain
//! `usize` values.
//!
//! Limits are policy values supplied by the host. Count values are observations
//! produced by parser, input, execution, or trace code. Keeping those roles in
//! distinct types prevents a source length, runtime input length, runtime state
//! length, return-output length, or trace-snapshot length from crossing into
//! the wrong budget by accident.
//!
//! ```
//! use rsaeb::limits::{
//! ExecutionLimits, ReturnByteLimit, RuntimeInputByteLimit, RuntimeInputLimits,
//! RuntimeStateByteLimit, StepLimit, TraceSnapshotByteLimit,
//! };
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let input_limits = RuntimeInputLimits::new(RuntimeInputByteLimit::new(4096));
//! let execution_limits = ExecutionLimits::new(
//! StepLimit::new(100),
//! RuntimeStateByteLimit::new(4096),
//! ReturnByteLimit::new(1024),
//! );
//!
//! if input_limits.input_byte_limit().get() != 4096 {
//! return Err("unexpected input limit".into());
//! }
//! if execution_limits.step_limit().get() != 100 {
//! return Err("unexpected step limit".into());
//! }
//! if TraceSnapshotByteLimit::new(2048).get() != 2048 {
//! return Err("unexpected trace limit".into());
//! }
//! # Ok(())
//! # }
//! ```
pub use crate;
pub use crate;