Struct domain::base::record::ParsedRecord
source · pub struct ParsedRecord<'a, Octs: Octets + ?Sized> { /* private fields */ }
Expand description
A raw record parsed from a message.
A value of this type contains the record header and the raw record data.
It is mainly used as an intermediary type when turning raw message data
into Record
s.
It allows access to the header only but can be traded for a real record
of a specific type of ParseRecordData
(i.e., some type that knowns
how to parse record data) via the to_record
and into_record
methods.
Implementations§
source§impl<'a, Octs: Octets + ?Sized> ParsedRecord<'a, Octs>
impl<'a, Octs: Octets + ?Sized> ParsedRecord<'a, Octs>
sourcepub fn new(
header: RecordHeader<ParsedDname<&'a Octs>>,
data: Parser<'a, Octs>,
) -> Self
pub fn new( header: RecordHeader<ParsedDname<&'a Octs>>, data: Parser<'a, Octs>, ) -> Self
Creates a new parsed record from a header and the record data.
The record data is provided via a parser that is positioned at the first byte of the record data.
sourcepub fn owner(&self) -> ParsedDname<&'a Octs>
pub fn owner(&self) -> ParsedDname<&'a Octs>
Returns a reference to the owner of the record.
source§impl<'a, Octs: Octets + ?Sized> ParsedRecord<'a, Octs>
impl<'a, Octs: Octets + ?Sized> ParsedRecord<'a, Octs>
sourcepub fn to_record<Data>(
&self,
) -> Result<Option<Record<ParsedDname<Octs::Range<'_>>, Data>>, ParseError>where
Data: ParseRecordData<'a, Octs>,
pub fn to_record<Data>(
&self,
) -> Result<Option<Record<ParsedDname<Octs::Range<'_>>, Data>>, ParseError>where
Data: ParseRecordData<'a, Octs>,
Creates a real resource record from the parsed record.
The method is generic over a type that knows how to parse record
data via the ParseRecordData
trait. The record data is given to
this trait for parsing. If the trait feels capable of parsing this
type of record (as indicated by the record type) and parsing succeeds,
the method returns Ok(Some(_))
. It returns Ok(None)
if the trait
doesn’t know how to parse this particular record type. It returns
an error if parsing fails.
sourcepub fn into_record<Data>(
self,
) -> Result<Option<Record<ParsedDname<Octs::Range<'a>>, Data>>, ParseError>where
Data: ParseRecordData<'a, Octs>,
pub fn into_record<Data>(
self,
) -> Result<Option<Record<ParsedDname<Octs::Range<'a>>, Data>>, ParseError>where
Data: ParseRecordData<'a, Octs>,
Trades the parsed record for a real resource record.
The method is generic over a type that knows how to parse record
data via the ParseRecordData
trait. The record data is given to
this trait for parsing. If the trait feels capable of parsing this
type of record (as indicated by the record type) and parsing succeeds,
the method returns Ok(Some(_))
. It returns Ok(None)
if the trait
doesn’t know how to parse this particular record type. It returns
an error if parsing fails.
Trait Implementations§
source§impl<'a, Octs: Clone + Octets + ?Sized> Clone for ParsedRecord<'a, Octs>
impl<'a, Octs: Clone + Octets + ?Sized> Clone for ParsedRecord<'a, Octs>
source§fn clone(&self) -> ParsedRecord<'a, Octs>
fn clone(&self) -> ParsedRecord<'a, Octs>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a, 'o, Octs, Other> PartialEq<ParsedRecord<'o, Other>> for ParsedRecord<'a, Octs>
impl<'a, 'o, Octs, Other> PartialEq<ParsedRecord<'o, Other>> for ParsedRecord<'a, Octs>
source§fn eq(&self, other: &ParsedRecord<'o, Other>) -> bool
fn eq(&self, other: &ParsedRecord<'o, Other>) -> bool
self
and other
values to be equal, and is used
by ==
.