Skip to main content

Meter

Trait Meter 

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§

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

Required Methods§

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

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

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".

Implementors§

§

impl Meter for LocalMeter<'_>

§

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

§

impl Meter for Unmetered

§

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