Trait domain::base::octets::Parse

source ·
pub trait Parse<Ref>: Sized {
    // Required methods
    fn parse(parser: &mut Parser<Ref>) -> Result<Self, ParseError>;
    fn skip(parser: &mut Parser<Ref>) -> Result<(), ParseError>;
}
Expand description

A type that can extract a value from a parser.

The trait is a companion to Parser<Ref>: it allows a type to use a parser to create a value of itself. Because types may be generic over octets types, the trait is generic over the octets reference of the parser in question. Implementations should use minimal trait bounds matching the parser methods they use.

For types that are generic over an octets sequence, the reference type should be tied to the type’s own type argument. This will avoid having to provide type annotations when simply calling Parse::parse for the type. Typically this will happen via OctetsRef::Range. For instance, a type Foo<Octets> should provide:

impl<Ref: OctetsRef> Parse<Ref> for Foo<Ref::Range> {
    // etc.
}

Required Methods§

source

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

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 is 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<Ref>) -> Result<(), ParseError>

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 the parser.

Implementations on Foreign Types§

source§

impl<T: AsRef<[u8]>> Parse<T> for i8

source§

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

source§

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

source§

impl<T: AsRef<[u8]>> Parse<T> for u16

source§

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

source§

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

source§

impl<T: AsRef<[u8]>> Parse<T> for i32

source§

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

source§

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

source§

impl<T: AsRef<[u8]>> Parse<T> for u32

source§

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

source§

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

source§

impl<T: AsRef<[u8]>> Parse<T> for i16

source§

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

source§

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

source§

impl<T: AsRef<[u8]>> Parse<T> for u8

source§

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

source§

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

source§

impl<Ref, Data> Parse<Ref> for Option<Record<ParsedDname<Ref>, Data>>where Ref: OctetsRef, Data: ParseRecordData<Ref>,

source§

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

source§

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

Implementors§

source§

impl<Octets: AsRef<[u8]>> Parse<Octets> for A

source§

impl<Octets: AsRef<[u8]>> Parse<Octets> for OptionHeader

source§

impl<Ref> Parse<Ref> for ParsedDname<Ref>where Ref: AsRef<[u8]> + Clone,

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Class

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for DigestAlg

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for ExtendedErrorCode

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Nsec3HashAlg

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Opcode

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for OptionCode

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for TsigRcode

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Rtype

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for SecAlg

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for SvcbParamKey

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Time48

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Aaaa

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for HeaderSection

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Expire

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for TcpKeepalive

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for Padding

source§

impl<Ref: AsRef<[u8]>> Parse<Ref> for ClientSubnet

source§

impl<Ref: OctetsRef> Parse<Ref> for AllParams<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Cname<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Hinfo<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Mb<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Md<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Mf<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Mg<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Minfo<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Mr<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Mx<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Ns<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Null<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Ptr<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Soa<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Txt<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Srv<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Tsig<Ref::Range, ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Dnskey<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Ds<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Nsec<Ref::Range, ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Rrsig<Ref::Range, ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for RtypeBitmap<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Nsec3<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Nsec3Salt<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Nsec3param<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for OwnerHash<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for domain::rdata::rfc6672::Dname<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Cdnskey<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Cds<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Alpn<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for DohPath<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Ech<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Ipv4Hint<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Ipv6Hint<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Mandatory<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for NoDefaultAlpn

source§

impl<Ref: OctetsRef> Parse<Ref> for Port

source§

impl<Ref: OctetsRef> Parse<Ref> for Https<Ref::Range, ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for Svcb<Ref::Range, ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for CharStr<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for domain::base::name::Dname<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Nsid<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Dau<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Dhu<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for N3u<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Chain<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for KeyTag<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for ExtendedError<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Opt<Ref::Range>

source§

impl<Ref: OctetsRef> Parse<Ref> for Question<ParsedDname<Ref>>

source§

impl<Ref: OctetsRef> Parse<Ref> for ParsedRecord<Ref>

source§

impl<Ref: OctetsRef> Parse<Ref> for RecordHeader<ParsedDname<Ref>>

source§

impl<T: AsRef<[u8]>> Parse<T> for Ipv4Addr

source§

impl<T: AsRef<[u8]>> Parse<T> for Ipv6Addr

source§

impl<T: AsRef<[u8]>> Parse<T> for Serial