Trait Input
pub trait Input: Clone + Sized
Parser input types must implement this trait
Associated Types
type Item;The current input type is a sequence of that
Itemtype.Example:
u8for&[u8]orcharfor&strtype Iter: Iterator<Item = Self::Item>;An iterator over the input type, producing the item
type IterIndices: Iterator<Item = (usize, Self::Item)>;An iterator over the input type, producing the item and its byte position If we're iterating over
&str, the position corresponds to the byte index of the character
Required Methods
fn input_len(&self) -> usizeCalculates the input length, as indicated by its name, and the name of the trait itself
fn take(&self, index: usize) -> SelfReturns a slice of
indexbytes. panics if index > lengthfn take_from(&self, index: usize) -> SelfReturns a slice starting at
indexbytes. panics if index > lengthfn take_split(&self, index: usize) -> (Self, Self)Split the stream at the
indexbyte offset. panics if index > lengthfn position<P>(&self, predicate: P) -> Option<usize> where P: Fn(Self::Item) -> bool,Returns the byte position of the first element satisfying the predicate
fn iter_elements(&self) -> Self::IterReturns an iterator over the elements
fn iter_indices(&self) -> Self::IterIndicesReturns an iterator over the elements and their byte offsets
fn slice_index(&self, count: usize) -> Result<usize, Needed>Get the byte offset from the element's position in the stream
Provided Methods
fn split_at_position<P, E: ParseError<Self>>(&self, predicate: P) -> IResult<Self, Self, E> where P: Fn(Self::Item) -> bool,Looks for the first element of the input type for which the condition returns true, and returns the input up to this position.
streaming version: If no element is found matching the condition, this will return
Incompletefn split_at_position1<P, E: ParseError<Self>>(&self, predicate: P, e: ErrorKind) -> IResult<Self, Self, E> where P: Fn(Self::Item) -> bool,Looks for the first element of the input type for which the condition returns true and returns the input up to this position.
Fails if the produced slice is empty.
streaming version: If no element is found matching the condition, this will return
Incompletefn split_at_position_complete<P, E: ParseError<Self>>(&self, predicate: P) -> IResult<Self, Self, E> where P: Fn(Self::Item) -> bool,Looks for the first element of the input type for which the condition returns true, and returns the input up to this position.
complete version: If no element is found matching the condition, this will return the whole input
fn split_at_position1_complete<P, E: ParseError<Self>>(&self, predicate: P, e: ErrorKind) -> IResult<Self, Self, E> where P: Fn(Self::Item) -> bool,Looks for the first element of the input type for which the condition returns true and returns the input up to this position.
Fails if the produced slice is empty.
complete version: If no element is found matching the condition, this will return the whole input
fn split_at_position_mode<OM: OutputMode, P, E: ParseError<Self>>(&self, predicate: P) -> PResult<OM, Self, Self, E> where P: Fn(Self::Item) -> bool,mode version of split_at_position
fn split_at_position_mode1<OM: OutputMode, P, E: ParseError<Self>>(&self, predicate: P, e: ErrorKind) -> PResult<OM, Self, Self, E> where P: Fn(Self::Item) -> bool,mode version of split_at_position