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§
Sourcefn add_depth(&mut self, depth: isize)
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.
Sourcefn estimate_lowest_possible_depth(&self) -> isize
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.
Sourcefn depth_at_end(&self) -> isize
fn depth_at_end(&self) -> isize
Returns exact depth at the end of the decorated slice.
Sourcefn advance_to_next_depth_decrease(&mut self) -> bool
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.