pub struct DecodeBudget { /* private fields */ }Expand description
Running counters for a single decode. Construct one per decode call.
Implementations§
Source§impl DecodeBudget
impl DecodeBudget
Sourcepub fn new(limits: DecodeLimits) -> Self
pub fn new(limits: DecodeLimits) -> Self
Create a fresh budget with zeroed counters for the given limits.
Sourcepub fn limits(&self) -> DecodeLimits
pub fn limits(&self) -> DecodeLimits
The DecodeLimits this budget enforces.
Sourcepub fn check_input_bytes(&self, codec: CodecId, len: usize) -> Result<()>
pub fn check_input_bytes(&self, codec: CodecId, len: usize) -> Result<()>
Check input size against DecodeLimits::max_input_bytes.
Sourcepub fn check_tokens(&self, codec: CodecId, count: usize) -> Result<()>
pub fn check_tokens(&self, codec: CodecId, count: usize) -> Result<()>
Check token count against DecodeLimits::max_tokens.
Sourcepub fn check_collection_len(&self, codec: CodecId, len: usize) -> Result<()>
pub fn check_collection_len(&self, codec: CodecId, len: usize) -> Result<()>
Check collection length against DecodeLimits::max_collection_len.
Sourcepub fn check_string_bytes(&self, codec: CodecId, len: usize) -> Result<()>
pub fn check_string_bytes(&self, codec: CodecId, len: usize) -> Result<()>
Check string length against DecodeLimits::max_string_bytes.
Sourcepub fn check_blob_bytes(&self, codec: CodecId, len: usize) -> Result<()>
pub fn check_blob_bytes(&self, codec: CodecId, len: usize) -> Result<()>
Check blob length against DecodeLimits::max_blob_bytes.
Sourcepub fn add_trivia(&mut self, codec: CodecId) -> Result<()>
pub fn add_trivia(&mut self, codec: CodecId) -> Result<()>
Charge one trivia item and check the running total against
DecodeLimits::max_trivia_items.
Sourcepub fn enter_node(&mut self, codec: CodecId, depth: usize) -> Result<()>
pub fn enter_node(&mut self, codec: CodecId, depth: usize) -> Result<()>
Charge one Expr node and check both the running node count against
DecodeLimits::max_expr_nodes and depth against
DecodeLimits::max_depth.
Auto Trait Implementations§
impl Freeze for DecodeBudget
impl RefUnwindSafe for DecodeBudget
impl Send for DecodeBudget
impl Sync for DecodeBudget
impl Unpin for DecodeBudget
impl UnsafeUnpin for DecodeBudget
impl UnwindSafe for DecodeBudget
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