pub trait Input: Sized {
type BlockIterator<'i, 'r, const N: usize, R>: InputBlockIterator<'i, N, Block = Self::Block<'i, N>>
where Self: 'i,
R: InputRecorder<Self::Block<'i, N>> + 'r;
type Block<'i, const N: usize>: InputBlock<'i, N>
where Self: 'i;
// Required methods
fn iter_blocks<'i, 'r, R, const N: usize>(
&'i self,
recorder: &'r R
) -> Self::BlockIterator<'i, 'r, N, R>
where R: InputRecorder<Self::Block<'i, N>>;
fn seek_backward(&self, from: usize, needle: u8) -> Option<usize>;
fn seek_forward<const N: usize>(
&self,
from: usize,
needles: [u8; N]
) -> Result<Option<(usize, u8)>, InputError>;
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 is_member_match(
&self,
from: usize,
to: usize,
member: &JsonString
) -> bool;
// Provided method
fn len_hint(&self) -> Option<usize> { ... }
}
Expand description
UTF-8 encoded bytes representing a JSON document that support block-by-block iteration and basic seeking procedures.
Required Associated Types§
sourcetype BlockIterator<'i, 'r, const N: usize, R>: InputBlockIterator<'i, N, Block = Self::Block<'i, N>>
where
Self: 'i,
R: InputRecorder<Self::Block<'i, N>> + 'r
type BlockIterator<'i, 'r, const N: usize, R>: InputBlockIterator<'i, N, Block = Self::Block<'i, N>> where Self: 'i, R: InputRecorder<Self::Block<'i, N>> + 'r
Type of the iterator used by iter_blocks
, parameterized
by the lifetime of source input and the size of the block.
sourcetype Block<'i, const N: usize>: InputBlock<'i, N>
where
Self: 'i
type Block<'i, const N: usize>: InputBlock<'i, N> where Self: 'i
Type of the blocks returned by the BlockIterator
.
Required Methods§
sourcefn iter_blocks<'i, 'r, R, const N: usize>(
&'i self,
recorder: &'r R
) -> Self::BlockIterator<'i, 'r, N, R>where
R: InputRecorder<Self::Block<'i, N>>,
fn iter_blocks<'i, 'r, R, const N: usize>( &'i self, recorder: &'r R ) -> Self::BlockIterator<'i, 'r, N, R>where R: InputRecorder<Self::Block<'i, N>>,
Iterate over blocks of size N
of the input.
N
has to be a power of two larger than 1.
sourcefn seek_backward(&self, from: usize, needle: u8) -> Option<usize>
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.
sourcefn seek_forward<const N: usize>(
&self,
from: usize,
needles: [u8; N]
) -> Result<Option<(usize, u8)>, InputError>
fn seek_forward<const N: usize>( &self, from: usize, needles: [u8; N] ) -> Result<Option<(usize, u8)>, InputError>
Search for an occurrence of any of the needles
in the input,
starting from from
and looking forward. Returns the index
of the first occurrence and the needle found, or None
if none of the needles
were not found.
Errors
This function can read more data from the input if no relevant characters are found in the current buffer, which can fail.
sourcefn seek_non_whitespace_forward(
&self,
from: usize
) -> Result<Option<(usize, u8)>, InputError>
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.
sourcefn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)>
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.
sourcefn is_member_match(&self, from: usize, to: usize, member: &JsonString) -> bool
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.