pub trait Input: Sized {
type BlockIterator<'i, 'r, R, const N: usize>: InputBlockIterator<'i, N, Block = Self::Block<'i, N>, Error = Self::Error>
where Self: 'i,
R: InputRecorder<Self::Block<'i, N>> + 'r;
type Error: Into<InputError>;
type Block<'i, const N: usize>: InputBlock<'i, N>
where Self: 'i;
// Required methods
fn leading_padding_len(&self) -> usize;
fn trailing_padding_len(&self) -> usize;
fn iter_blocks<'i, 'r, R, const N: usize>(
&'i self,
recorder: &'r R,
) -> Self::BlockIterator<'i, 'r, R, N>
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)>, Self::Error>;
fn seek_non_whitespace_forward(
&self,
from: usize,
) -> Result<Option<(usize, u8)>, Self::Error>;
fn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)>;
fn is_member_match(
&self,
from: usize,
to: usize,
member: &StringPattern,
) -> Result<bool, Self::Error>;
// 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, R, const N: usize>: InputBlockIterator<'i, N, Block = Self::Block<'i, N>, Error = Self::Error>
where
Self: 'i,
R: InputRecorder<Self::Block<'i, N>> + 'r
type BlockIterator<'i, 'r, R, const N: usize>: InputBlockIterator<'i, N, Block = Self::Block<'i, N>, Error = Self::Error> 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 Error: Into<InputError>
type Error: Into<InputError>
Type of errors that can occur when operating on this Input
.
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 leading_padding_len(&self) -> usize
fn leading_padding_len(&self) -> usize
Return the length of the padding added at the start of the input.
This depends on the particular Input
implementation, and may be zero.
In any case the length of the entire input should be equivalent to the length
of the source plus leading_padding_len
plus
trailing_padding_len
.
Sourcefn trailing_padding_len(&self) -> usize
fn trailing_padding_len(&self) -> usize
Return the length of the padding added at the end of the input.
This depends on the particular Input
implementation, and may be zero.
In any case the length of the entire input should be equivalent to the length
of the source plus leading_padding_len
plus
trailing_padding_len
.
Sourcefn iter_blocks<'i, 'r, R, const N: usize>(
&'i self,
recorder: &'r R,
) -> Self::BlockIterator<'i, 'r, R, N>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, R, N>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)>, Self::Error>
fn seek_forward<const N: usize>( &self, from: usize, needles: [u8; N], ) -> Result<Option<(usize, u8)>, Self::Error>
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)>, Self::Error>
fn seek_non_whitespace_forward( &self, from: usize, ) -> Result<Option<(usize, u8)>, Self::Error>
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: &StringPattern,
) -> Result<bool, Self::Error>
fn is_member_match( &self, from: usize, to: usize, member: &StringPattern, ) -> Result<bool, Self::Error>
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.
§Errors
This function can read more data from the input if to
falls beyond
the range that was already read, and the read operation can fail.
Provided Methods§
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.