Trait Parse

Source
pub trait Parse: Sized {
    type Err: From<ShortBuf>;

    // Required methods
    fn parse(parser: &mut Parser) -> Result<Self, Self::Err>;
    fn skip(parser: &mut Parser) -> Result<(), Self::Err>;
}
Expand description

A type that can extract a value from the beginning of a parser.

Types that implement this trait must use an encoding where the end of a value in the parser can be determined from data read so far. These are either fixed length types like u32 or types that either contain length bytes or boundary markers.

Required Associated Types§

Source

type Err: From<ShortBuf>

The type of an error returned when parsing fails.

Required Methods§

Source

fn parse(parser: &mut Parser) -> Result<Self, Self::Err>

Extracts a value from the beginning of parser.

If parsing fails and an error is returned, the parser’s position should be considered to be undefined. If it supposed to be reused in this case, you should store the position before attempting to parse and seek to that position again before continuing.

Source

fn skip(parser: &mut Parser) -> Result<(), Self::Err>

Skips over a value of this type at the beginning of parser.

This function is the same as parse but doesn’t return the result. It can be used to check if the content of parser is correct or to skip over unneeded parts of a message.

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 i8

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, ShortBuf>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl Parse for i16

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, ShortBuf>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl Parse for i32

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, ShortBuf>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl Parse for u8

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, ShortBuf>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl Parse for u16

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, ShortBuf>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl Parse for u32

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, ShortBuf>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl Parse for Ipv4Addr

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, ShortBuf>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl Parse for Ipv6Addr

Source§

type Err = ShortBuf

Source§

fn parse(parser: &mut Parser) -> Result<Self, Self::Err>

Source§

fn skip(parser: &mut Parser) -> Result<(), ShortBuf>

Source§

impl<D: ParseRecordData> Parse for Option<Record<ParsedDname, D>>

Source§

type Err = RecordParseError<ParsedDnameError, <D as ParseRecordData>::Err>

Source§

fn parse(parser: &mut Parser) -> Result<Self, Self::Err>

Source§

fn skip(parser: &mut Parser) -> Result<(), Self::Err>

Implementors§

Source§

impl Parse for Class

Source§

impl Parse for DigestAlg

Source§

impl Parse for Nsec3HashAlg

Source§

impl Parse for OptionCode

Source§

impl Parse for Rtype

Source§

impl Parse for SecAlg

Source§

impl Parse for A

Source§

impl Parse for Cname<ParsedDname>

Source§

impl Parse for Hinfo

Source§

impl Parse for Mb<ParsedDname>

Source§

impl Parse for Md<ParsedDname>

Source§

impl Parse for Mf<ParsedDname>

Source§

impl Parse for Mg<ParsedDname>

Source§

impl Parse for Mr<ParsedDname>

Source§

impl Parse for Ns<ParsedDname>

Source§

impl Parse for Ptr<ParsedDname>

Source§

impl Parse for Aaaa

Source§

impl Parse for Nsec3param

Source§

impl Parse for CharStr

Source§

impl Parse for HeaderSection

Source§

impl Parse for Dname

Source§

impl Parse for ParsedDname

Source§

impl Parse for OptionHeader

Source§

impl Parse for ParsedRecord

Source§

impl Parse for RecordHeader<ParsedDname>

Source§

impl Parse for Serial

Source§

type Err = <u32 as Parse>::Err

Source§

impl<N: ToDname + Parse> Parse for Question<N>

Source§

type Err = <N as Parse>::Err

Source§

impl<N: Parse> Parse for Minfo<N>

Source§

type Err = <N as Parse>::Err

Source§

impl<N: Parse> Parse for Mx<N>
where N::Err: From<ShortBuf>,

Source§

type Err = <N as Parse>::Err

Source§

impl<N: Parse> Parse for Soa<N>
where N::Err: From<ShortBuf>,

Source§

type Err = <N as Parse>::Err

Source§

impl<N: Parse> Parse for Srv<N>

Source§

type Err = <N as Parse>::Err