Trait DepthBlock

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

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§