pub trait DepthBlock<'a>: Sized {
    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

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

Returns depth at the current position.

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.

Returns exact depth at the end of the decorated slice.

Advance to the next position at which depth may decrease.

Implementors