pub trait DepthBlock<'a>: Sized {
    // Required methods
    fn add_depth(&mut self, depth: isize);
    fn get_depth(&self) -> isize;
    fn estimate_lowest_possible_depth(&self) -> isize;
    fn depth_at_end(&self) -> isize;
    fn advance_to_next_depth_decrease(&mut self) -> bool;
}
Expand description

Common trait for structs that enrich a byte block with JSON depth information.

Required Methods§

source

fn add_depth(&mut self, depth: isize)

Add depth to the block. This is usually done at the start of a block to carry any accumulated depth over.

source

fn get_depth(&self) -> isize

Returns depth at the current position.

source

fn estimate_lowest_possible_depth(&self) -> isize

A lower bound on the depth that can be reached when advancing.

It is guaranteed that get_depth will always return something greater or equal to this return value, but it is not guaranteed to be a depth that is actually achievable within the block. In particular, an implementation always returning isize::MIN is a correct implementation. This is meant to be a tool for performance improvements, not reliably checking the actual minimal depth within the block.

source

fn depth_at_end(&self) -> isize

Returns exact depth at the end of the decorated slice.

source

fn advance_to_next_depth_decrease(&mut self) -> bool

Advance to the next position at which depth may decrease.

Returns

false if the end of the block was reached without any depth decrease, true otherwise.

Implementors§