#[non_exhaustive]pub struct ResourceBudget {
pub max_steps: Option<u64>,
pub max_value_elements: Option<usize>,
}Expand description
Evaluator-side resource budget.
ResourceBudget is deliberately separate from Capabilities:
capabilities answer “may the program use this host authority?”, while a
budget answers “how much evaluator work/value growth is this host willing
to pay for?”. The current implementation still stores these two fields on
Capabilities for compatibility; call Self::apply_to_capabilities to
bridge the new model into the existing evaluator.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_steps: Option<u64>Maximum evaluator steps. None is unbounded.
max_value_elements: Option<usize>Maximum number of elements in a single List/Tuple/Dict. None is
unbounded.
Implementations§
Source§impl ResourceBudget
impl ResourceBudget
pub const DEV_MAX_STEPS: u64 = 5_000_000
pub const DEV_MAX_VALUE_ELEMENTS: usize = 100_000
pub const UNTRUSTED_MAX_STEPS: u64 = 1_000_000
pub const UNTRUSTED_MAX_VALUE_ELEMENTS: usize = 10_000
Sourcepub fn off() -> ResourceBudget
pub fn off() -> ResourceBudget
No evaluator-side budget.
Sourcepub fn dev() -> ResourceBudget
pub fn dev() -> ResourceBudget
Local-development guardrails.
Sourcepub fn untrusted() -> ResourceBudget
pub fn untrusted() -> ResourceBudget
Tighter evaluator guardrails for externally supplied source.
pub fn from_profile(profile: ResourceBudgetProfile) -> ResourceBudget
pub fn has_evaluator_limits(self) -> bool
pub fn apply_to_capabilities(self, caps: &mut Capabilities)
Trait Implementations§
Source§impl Clone for ResourceBudget
impl Clone for ResourceBudget
Source§fn clone(&self) -> ResourceBudget
fn clone(&self) -> ResourceBudget
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ResourceBudget
Source§impl Debug for ResourceBudget
impl Debug for ResourceBudget
Source§impl Default for ResourceBudget
impl Default for ResourceBudget
Source§fn default() -> ResourceBudget
fn default() -> ResourceBudget
Returns the “default value” for a type. Read more
impl Eq for ResourceBudget
Source§impl PartialEq for ResourceBudget
impl PartialEq for ResourceBudget
Source§fn eq(&self, other: &ResourceBudget) -> bool
fn eq(&self, other: &ResourceBudget) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ResourceBudget
Auto Trait Implementations§
impl Freeze for ResourceBudget
impl RefUnwindSafe for ResourceBudget
impl Send for ResourceBudget
impl Sync for ResourceBudget
impl Unpin for ResourceBudget
impl UnsafeUnpin for ResourceBudget
impl UnwindSafe for ResourceBudget
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
Mutably borrows from an owned value. Read more
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more