Skip to main content

WireBudget

Struct WireBudget 

Source
pub struct WireBudget { /* private fields */ }
Expand description

Mutable accounting state shared by one complete wire decode.

Implementations§

Source§

impl WireBudget

Source

pub const fn limits(&self) -> WireLimits

Returns the configured limits for this session.

Source

pub fn check_node(&mut self) -> Result<(), ValueWireDecodeError>

Charges one decoded node.

Source

pub fn check_depth(&self, depth: usize) -> Result<(), ValueWireDecodeError>

Checks a recursive depth.

Source

pub fn check_collection_items( &self, items: usize, ) -> Result<(), ValueWireDecodeError>

Checks one collection length.

Source

pub fn check_map_entries( &self, entries: usize, ) -> Result<(), ValueWireDecodeError>

Checks one map length.

Source

pub fn check_string_bytes( &self, bytes: usize, ) -> Result<(), ValueWireDecodeError>

Checks one decoded string length.

Source

pub fn check_numeric_bytes( &self, bytes: usize, ) -> Result<(), ValueWireDecodeError>

Checks one decoded numeric representation length in UTF-8 bytes.

Source

pub fn check_container( &mut self, container: &ValueContainer, ) -> Result<(), ValueWireDecodeError>

Validates a decoded value container against the shared budget.

Source

pub fn check_container_at( &mut self, container: &ValueContainer, depth: usize, ) -> Result<(), ValueWireDecodeError>

Validates one decoded value container at depth.

Source

pub fn check_value(&mut self, value: &Value) -> Result<(), ValueWireDecodeError>

Validates one scalar Value against the shared budget.

Source

pub fn check_multi_values( &mut self, values: &MultiValues, ) -> Result<(), ValueWireDecodeError>

Validates one homogeneous collection against the shared budget.

§Parameters
  • values - Collection whose elements are charged to this budget.
§Errors

Returns a resource-limit error when the collection exceeds the configured depth, node, item, string, map, or numeric limits.

Source

pub fn check_multi_values_at( &mut self, values: &MultiValues, depth: usize, ) -> Result<(), ValueWireDecodeError>

Validates one homogeneous collection at an embedding depth.

§Parameters
  • values - Collection whose elements are charged to this budget.
  • depth - Root-inclusive depth of the collection.
§Errors

Returns a resource-limit error when the collection exceeds the configured depth, node, item, string, map, or numeric limits.

Source

pub fn check_named_value( &mut self, value: &NamedValue, ) -> Result<(), ValueWireDecodeError>

Validates a named scalar and reuses scalar budget accounting.

§Parameters
  • value - Named scalar to validate.
§Errors

Returns a resource-limit error for the wrapper name or nested value.

Source

pub fn check_named_value_at( &mut self, value: &NamedValue, depth: usize, ) -> Result<(), ValueWireDecodeError>

Validates a named scalar at an embedding depth.

§Parameters
  • value - Named scalar to validate.
  • depth - Root-inclusive depth of the named wrapper.
§Errors

Returns a resource-limit error for the wrapper name or nested value.

Source

pub fn check_named_multi_values( &mut self, value: &NamedMultiValues, ) -> Result<(), ValueWireDecodeError>

Validates a named collection and reuses collection budget accounting.

§Parameters
  • value - Named collection to validate.
§Errors

Returns a resource-limit error for the wrapper name or nested values.

Source

pub fn check_named_multi_values_at( &mut self, value: &NamedMultiValues, depth: usize, ) -> Result<(), ValueWireDecodeError>

Validates a named collection at an embedding depth.

§Parameters
  • value - Named collection to validate.
  • depth - Root-inclusive depth of the named wrapper.
§Errors

Returns a resource-limit error for the wrapper name or nested values.

Source

pub fn check_value_at( &mut self, value: &Value, depth: usize, ) -> Result<(), ValueWireDecodeError>

Validates one scalar value at an embedding depth.

Use this method when the scalar is nested inside an outer wire document. The depth is inclusive and should be supplied by the outer protocol’s accounting traversal.

§Parameters
  • value - Scalar value to validate.
  • depth - Root-inclusive depth of the scalar in the complete document.
§Errors

Returns a resource-limit error when the value exceeds the configured depth, node, string, or numeric budget.

Trait Implementations§

Source§

impl Debug for WireBudget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoValueDefault<T> for T

Source§

fn into_value_default(self) -> T

Converts this argument into the default value. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.