pub struct Budget {
pub max_nodes: u64,
pub max_depth: u64,
pub max_array_len: u64,
pub max_keys: u64,
pub max_wall_ms: u64,
pub max_value_size: u64,
pub max_total_value_size: u64,
}Expand description
Runtime resource limits enforced by the evaluator accountant
(spec/budgets.md §2, C-037). Every field 0 means unlimited —
the embedder accepts the risk explicitly.
Fields§
§max_nodes: u64Maximum IR nodes visited (arena-length pre-check).
max_depth: u64Maximum value nesting depth (reference-aware).
max_array_len: u64Longest single array.
max_keys: u64Total value-table keys across the arena (schema tables excluded: they are metadata, validated separately).
max_wall_ms: u64Wall-clock milliseconds for the whole evaluation.
max_value_size: u64Maximum materialized value size in data units (scalars and
string bytes), counting reference expansion: each Ref clone
costs its target’s bound. Kills exponential blowup
(billion-laughs class) before anything materializes.
max_total_value_size: u64Maximum cumulative materialized size across the whole evaluation (same units). Per-node bounds cap each clone; this caps their sum — many aliases of one large value trip here even when every node is individually fine.
Implementations§
Source§impl Budget
impl Budget
Sourcepub fn wall_deadline(&self) -> Option<Instant>
pub fn wall_deadline(&self) -> Option<Instant>
Absolute evaluation deadline, or None when the wall-clock
budget is disabled (max_wall_ms == 0). Saturating: absurd
configured durations degrade to no deadline instead of
panicking on Instant overflow.
Platform delta (G-003): Instant aborts on
wasm32-unknown-unknown, so wall-clock degrades to disabled there
(this function returns None). Count, depth, array, key, and
value-size budgets still bound execution, and the regex crate
guarantees linear-time matching, so no wall-clock backstop is
needed for termination on that target; hosts enforce their own
timeouts (Worker terminate pattern). See wall_supported.
Sourcepub fn wall_supported() -> bool
pub fn wall_supported() -> bool
False on targets without a monotonic clock (wasm32-unknown-unknown)
and under Miri (its mock clock advances with interpreted work, so
any wall budget would trip spuriously while count, depth, array,
key, and value-size budgets still bind execution there):
wall_deadline degrades to None in both cases. Hosts must check
this when they promise wall-clock enforcement to their own callers.
Trait Implementations§
impl Copy for Budget
impl Eq for Budget
impl StructuralPartialEq for Budget
Auto Trait Implementations§
impl Freeze for Budget
impl RefUnwindSafe for Budget
impl Send for Budget
impl Sync for Budget
impl Unpin for Budget
impl UnsafeUnpin for Budget
impl UnwindSafe for Budget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.