Trait rsonpath::input::Input

source ·
pub trait Input: Sized {
    type BlockIterator<'a, const N: usize>: InputBlockIterator<'a, N>
       where Self: 'a;

    // Required methods
    fn iter_blocks<const N: usize>(&self) -> Self::BlockIterator<'_, N>;
    fn seek_backward(&self, from: usize, needle: u8) -> Option<usize>;
    fn seek_non_whitespace_forward(
        &self,
        from: usize
    ) -> Result<Option<(usize, u8)>, InputError>;
    fn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)>;
    fn find_member(
        &self,
        from: usize,
        member: &JsonString
    ) -> Result<Option<usize>, InputError>;
    fn is_member_match(
        &self,
        from: usize,
        to: usize,
        member: &JsonString
    ) -> bool;
}
Expand description

UTF-8 encoded bytes representing a JSON document that support block-by-block iteration and basic seeking procedures.

Required Associated Types§

source

type BlockIterator<'a, const N: usize>: InputBlockIterator<'a, N> where Self: 'a

Type of the iterator used by iter_blocks, parameterized by the lifetime of source input and the size of the block.

Required Methods§

source

fn iter_blocks<const N: usize>(&self) -> Self::BlockIterator<'_, N>

Iterate over blocks of size N of the input. N has to be a power of two larger than 1.

source

fn seek_backward(&self, from: usize, needle: u8) -> Option<usize>

Search for an occurrence of needle in the input, starting from from and looking back. Returns the index of the first occurrence or None if the needle was not found.

source

fn seek_non_whitespace_forward( &self, from: usize ) -> Result<Option<(usize, u8)>, InputError>

Search for the first byte in the input that is not ASCII whitespace starting from from. Returns a pair: the index of first such byte, and the byte itself; or None if no non-whitespace characters were found.

Errors

This function can read more data from the input if no relevant characters are found in the current buffer, which can fail.

source

fn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)>

Search for the first byte in the input that is not ASCII whitespace starting from from and looking back. Returns a pair: the index of first such byte, and the byte itself; or None if no non-whitespace characters were found.

source

fn find_member( &self, from: usize, member: &JsonString ) -> Result<Option<usize>, InputError>

Search the input for the first occurrence of member name member (comparing bitwise, including double quotes delimiters) starting from from. Returns the index of the first occurrence, or None if no occurrence was found.

This will also check if the leading double quote is not escaped by a backslash character, but will ignore any other structural properties of the input. In particular, the member might be found at an arbitrary depth.

Errors

This function can read more data from the input if no relevant characters are found in the current buffer, which can fail.

source

fn is_member_match(&self, from: usize, to: usize, member: &JsonString) -> bool

Decide whether the slice of input between from (inclusive) and to (exclusive) matches the member (comparing bitwise, including double quotes delimiters).

This will also check if the leading double quote is not escaped by a backslash character.

Implementors§

source§

impl Input for MmapInput

source§

impl Input for OwnedBytes

source§

impl<'a> Input for BorrowedBytes<'a>

§

type BlockIterator<'b, const N: usize> where Self: 'b = BorrowedBytesBlockIterator<'b, N>

source§

impl<R: Read> Input for BufferedInput<R>

§

type BlockIterator<'a, const N: usize> where Self: 'a = BufferedInputBlockIterator<'a, R, N>