rocket::mtls::oid::asn1_rs::nom

Trait InputTakeAtPosition

Source
pub trait InputTakeAtPosition: Sized {
    type Item;

    // Required methods
    fn split_at_position<P, E>(
        &self,
        predicate: P,
    ) -> Result<(Self, Self), Err<E>>
       where E: ParseError<Self>,
             P: Fn(Self::Item) -> bool;
    fn split_at_position1<P, E>(
        &self,
        predicate: P,
        e: ErrorKind,
    ) -> Result<(Self, Self), Err<E>>
       where E: ParseError<Self>,
             P: Fn(Self::Item) -> bool;
    fn split_at_position_complete<P, E>(
        &self,
        predicate: P,
    ) -> Result<(Self, Self), Err<E>>
       where E: ParseError<Self>,
             P: Fn(Self::Item) -> bool;
    fn split_at_position1_complete<P, E>(
        &self,
        predicate: P,
        e: ErrorKind,
    ) -> Result<(Self, Self), Err<E>>
       where E: ParseError<Self>,
             P: Fn(Self::Item) -> bool;
}
Available on crate feature mtls only.
Expand description

Methods to take as much input as possible until the provided function returns true for the current element.

A large part of nom’s basic parsers are built using this trait.

Required Associated Types§

Source

type Item

The current input type is a sequence of that Item type.

Example: u8 for &[u8] or char for &str

Required Methods§

Source

fn split_at_position<P, E>(&self, predicate: P) -> Result<(Self, Self), Err<E>>
where E: ParseError<Self>, 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 Incomplete

Source

fn split_at_position1<P, E>( &self, predicate: P, e: ErrorKind, ) -> Result<(Self, Self), Err<E>>
where E: ParseError<Self>, 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 Incomplete

Source

fn split_at_position_complete<P, E>( &self, predicate: P, ) -> Result<(Self, Self), Err<E>>
where E: ParseError<Self>, 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

Source

fn split_at_position1_complete<P, E>( &self, predicate: P, e: ErrorKind, ) -> Result<(Self, Self), Err<E>>
where E: ParseError<Self>, 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

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.

Implementations on Foreign Types§

Source§

impl<'a> InputTakeAtPosition for &'a str

Source§

type Item = char

Source§

fn split_at_position<P, E>( &self, predicate: P, ) -> Result<(&'a str, &'a str), Err<E>>
where E: ParseError<&'a str>, P: Fn(<&'a str as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position1<P, E>( &self, predicate: P, e: ErrorKind, ) -> Result<(&'a str, &'a str), Err<E>>
where E: ParseError<&'a str>, P: Fn(<&'a str as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position_complete<P, E>( &self, predicate: P, ) -> Result<(&'a str, &'a str), Err<E>>
where E: ParseError<&'a str>, P: Fn(<&'a str as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position1_complete<P, E>( &self, predicate: P, e: ErrorKind, ) -> Result<(&'a str, &'a str), Err<E>>
where E: ParseError<&'a str>, P: Fn(<&'a str as InputTakeAtPosition>::Item) -> bool,

Source§

impl<'a> InputTakeAtPosition for &'a [u8]

Source§

type Item = u8

Source§

fn split_at_position<P, E>( &self, predicate: P, ) -> Result<(&'a [u8], &'a [u8]), Err<E>>
where E: ParseError<&'a [u8]>, P: Fn(<&'a [u8] as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position1<P, E>( &self, predicate: P, e: ErrorKind, ) -> Result<(&'a [u8], &'a [u8]), Err<E>>
where E: ParseError<&'a [u8]>, P: Fn(<&'a [u8] as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position_complete<P, E>( &self, predicate: P, ) -> Result<(&'a [u8], &'a [u8]), Err<E>>
where E: ParseError<&'a [u8]>, P: Fn(<&'a [u8] as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position1_complete<P, E>( &self, predicate: P, e: ErrorKind, ) -> Result<(&'a [u8], &'a [u8]), Err<E>>
where E: ParseError<&'a [u8]>, P: Fn(<&'a [u8] as InputTakeAtPosition>::Item) -> bool,

Implementors§