Trait Parse

Source
pub trait Parse {
    type Output;
    type Error;

    // Required method
    fn parse(buff: &[u8]) -> Result<(Self::Output, usize), Self::Error>;

    // Provided method
    fn parse_iter<'a>(
        buff: &'a [u8],
    ) -> ParseIter<'a, Self::Output, Self::Error>  { ... }
}
Expand description

Parse trait for building parse-able objects

Required Associated Types§

Source

type Output

Output type returned from parsing

Source

type Error

Error type returned on parse error

Required Methods§

Source

fn parse(buff: &[u8]) -> Result<(Self::Output, usize), Self::Error>

Parse method consumes a slice and returns an object and the remaining slice.

Provided Methods§

Source

fn parse_iter<'a>(buff: &'a [u8]) -> ParseIter<'a, Self::Output, Self::Error>

Parse iter consumes a slice and returns an iterator over decoded objects

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 Parse for String

Source§

type Output = String

Source§

type Error = OptionsError

Source§

fn parse<'a>(data: &[u8]) -> Result<(Self::Output, usize), Self::Error>

Source§

impl Parse for Vec<u8>

Source§

type Output = Vec<u8>

Source§

type Error = OptionsError

Source§

fn parse<'a>(data: &[u8]) -> Result<(Self::Output, usize), Self::Error>

Implementors§