Skip to main content

DepthCounter

Trait DepthCounter 

Source
pub trait DepthCounter: Debug + Copy {
    // Required methods
    fn zero() -> Self;
    fn increment(self) -> (Self, bool);
    fn decrement(self) -> (Self, bool);
    fn is_zero(self) -> bool;
}
Expand description

Trait for depth counters - tracks nesting depth.

This trait provides overflow-safe operations for tracking JSON nesting depth. Implemented for all unsigned integer types.

Required Methods§

Source

fn zero() -> Self

Create a zero depth value

Source

fn increment(self) -> (Self, bool)

Increment depth, returning (new_value, overflow_occurred)

Source

fn decrement(self) -> (Self, bool)

Decrement depth, returning (new_value, underflow_occurred)

Source

fn is_zero(self) -> bool

Check if depth is zero

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DepthCounter for u8

Source§

fn zero() -> Self

Source§

fn increment(self) -> (Self, bool)

Source§

fn decrement(self) -> (Self, bool)

Source§

fn is_zero(self) -> bool

Source§

impl DepthCounter for u16

Source§

fn zero() -> Self

Source§

fn increment(self) -> (Self, bool)

Source§

fn decrement(self) -> (Self, bool)

Source§

fn is_zero(self) -> bool

Source§

impl DepthCounter for u32

Source§

fn zero() -> Self

Source§

fn increment(self) -> (Self, bool)

Source§

fn decrement(self) -> (Self, bool)

Source§

fn is_zero(self) -> bool

Source§

impl DepthCounter for u64

Source§

fn zero() -> Self

Source§

fn increment(self) -> (Self, bool)

Source§

fn decrement(self) -> (Self, bool)

Source§

fn is_zero(self) -> bool

Source§

impl DepthCounter for u128

Source§

fn zero() -> Self

Source§

fn increment(self) -> (Self, bool)

Source§

fn decrement(self) -> (Self, bool)

Source§

fn is_zero(self) -> bool

Source§

impl DepthCounter for usize

Source§

fn zero() -> Self

Source§

fn increment(self) -> (Self, bool)

Source§

fn decrement(self) -> (Self, bool)

Source§

fn is_zero(self) -> bool

Implementors§