[−][src]Trait domain::base::octets::Parse
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
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.
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
impl<T: AsRef<[u8]>> Parse<T> for i8
[src]
fn parse(parser: &mut Parser<T>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<T>) -> Result<(), ParseError>
[src]
impl<T: AsRef<[u8]>> Parse<T> for u8
[src]
fn parse(parser: &mut Parser<T>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<T>) -> Result<(), ParseError>
[src]
impl<T: AsRef<[u8]>> Parse<T> for i16
[src]
fn parse(parser: &mut Parser<T>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<T>) -> Result<(), ParseError>
[src]
impl<T: AsRef<[u8]>> Parse<T> for u16
[src]
fn parse(parser: &mut Parser<T>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<T>) -> Result<(), ParseError>
[src]
impl<T: AsRef<[u8]>> Parse<T> for i32
[src]
fn parse(parser: &mut Parser<T>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<T>) -> Result<(), ParseError>
[src]
impl<T: AsRef<[u8]>> Parse<T> for u32
[src]
fn parse(parser: &mut Parser<T>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<T>) -> Result<(), ParseError>
[src]
impl<Ref, Data> Parse<Ref> for Option<Record<ParsedDname<Ref>, Data>> where
Ref: OctetsRef,
Data: ParseRecordData<Ref>,
[src]
Ref: OctetsRef,
Data: ParseRecordData<Ref>,
fn parse(parser: &mut Parser<Ref>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<Ref>) -> Result<(), ParseError>
[src]
Implementors
impl<Octets: AsRef<[u8]>> Parse<Octets> for OptionHeader
[src]
fn parse(parser: &mut Parser<Octets>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<Octets>) -> Result<(), ParseError>
[src]
impl<Octets: AsRef<[u8]>> Parse<Octets> for A
[src]
fn parse(parser: &mut Parser<Octets>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<Octets>) -> Result<(), ParseError>
[src]
impl<Ref> Parse<Ref> for ParsedDname<Ref> where
Ref: AsRef<[u8]> + Clone,
[src]
Ref: AsRef<[u8]> + Clone,
fn parse(parser: &mut Parser<Ref>) -> Result<Self, ParseError>
[src]
fn skip(parser: &mut Parser<Ref>) -> Result<(), ParseError>
[src]
Skip over a domain name.
This will only check the uncompressed part of the name. If the name is compressed but the compression pointer is invalid or the name pointed to is invalid or too long, the function will still succeed.
If you need to check that the name you are skipping over is valid, you
will have to use parse
and drop the result.