Meter

Trait Meter 

Source
pub trait Meter {
    type Nested<'a>: Meter
       where Self: 'a;

    // Required methods
    fn nest(&mut self) -> Result<Self::Nested<'_>, MeterError>;
    fn charge(&mut self, amount: usize) -> Result<(), MeterError>;
}
Expand description

A trait for tracking the resource limits consumed while serializing a value.

Required Associated Types§

Source

type Nested<'a>: Meter where Self: 'a

Required Methods§

Source

fn nest(&mut self) -> Result<Self::Nested<'_>, MeterError>

Produce a new meter for nested contexts, consuming one unit of nesting budget.

Source

fn charge(&mut self, amount: usize) -> Result<(), MeterError>

Charge amount units against the remaining size budget.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Meter for LocalMeter<'_>

Source§

type Nested<'a> = LocalMeter<'a> where Self: 'a

Source§

impl Meter for Unmetered

Source§

type Nested<'a> = Unmetered where Self: 'a