pub struct Opt<Octets> { /* private fields */ }
Expand description
OPT record data.
This is the record data type for OPT records and can be used as the data
type parameter in Record
. It simply wraps an octets sequence with all
the record data. It guarantees that the data contains a correctly
formatted sequence of options but doesn’t guarantee that the options
themselves are correct. You can iterate over options via the iter
method.
Since some of the information of the OPT record is transmitted in the
record header, a special type OptRecord
exists, that contains all
the OPT data which is the preferred way of accessing this data.
Implementations
sourceimpl<Octets: AsRef<[u8]>> Opt<Octets>
impl<Octets: AsRef<[u8]>> Opt<Octets>
sourcepub fn from_octets(octets: Octets) -> Result<Self, ParseError>
pub fn from_octets(octets: Octets) -> Result<Self, ParseError>
Creates OPT record data from an octets sequence.
The function checks whether the octets contain a sequence of options. It does not check whether the options themselves are valid.
sourcepub fn iter<Data>(&self) -> OptIter<&Octets, Data>ⓘNotable traits for OptIter<Ref, Data>impl<Ref, Data> Iterator for OptIter<Ref, Data>where
Ref: OctetsRef,
Data: ParseOptData<Ref>, type Item = Result<Data, ParseError>;
where
for<'a> &'a Octets: OctetsRef,
Data: for<'a> ParseOptData<&'a Octets>,
pub fn iter<Data>(&self) -> OptIter<&Octets, Data>ⓘNotable traits for OptIter<Ref, Data>impl<Ref, Data> Iterator for OptIter<Ref, Data>where
Ref: OctetsRef,
Data: ParseOptData<Ref>, type Item = Result<Data, ParseError>;
where
for<'a> &'a Octets: OctetsRef,
Data: for<'a> ParseOptData<&'a Octets>,
Ref: OctetsRef,
Data: ParseOptData<Ref>, type Item = Result<Data, ParseError>;
Returns an iterator over options of a given type.
The returned iterator will return only options represented by type
D
and quietly skip over all the others.
Trait Implementations
sourceimpl<Octets: AsRef<[u8]>> Compose for Opt<Octets>
impl<Octets: AsRef<[u8]>> Compose for Opt<Octets>
sourcefn compose<T: OctetsBuilder + AsMut<[u8]>>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
fn compose<T: OctetsBuilder + AsMut<[u8]>>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
Appends the concrete representation of the value to the target. Read more
sourcefn compose_canonical<T: OctetsBuilder + AsMut<[u8]>>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
fn compose_canonical<T: OctetsBuilder + AsMut<[u8]>>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
Appends the canonical representation of the value to the target. Read more
sourceimpl<O, N> From<Opt<O>> for AllRecordData<O, N>
impl<O, N> From<Opt<O>> for AllRecordData<O, N>
sourceimpl<Octets, SrcOctets> OctetsFrom<Opt<SrcOctets>> for Opt<Octets>where
Octets: OctetsFrom<SrcOctets>,
impl<Octets, SrcOctets> OctetsFrom<Opt<SrcOctets>> for Opt<Octets>where
Octets: OctetsFrom<SrcOctets>,
sourcefn octets_from(source: Opt<SrcOctets>) -> Result<Self, ShortBuf>
fn octets_from(source: Opt<SrcOctets>) -> Result<Self, ShortBuf>
Performs the conversion.
sourceimpl<Octets: AsRef<[u8]>> Ord for Opt<Octets>
impl<Octets: AsRef<[u8]>> Ord for Opt<Octets>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<Octets, Other> PartialEq<Opt<Other>> for Opt<Octets>where
Octets: AsRef<[u8]>,
Other: AsRef<[u8]>,
impl<Octets, Other> PartialEq<Opt<Other>> for Opt<Octets>where
Octets: AsRef<[u8]>,
Other: AsRef<[u8]>,
sourceimpl<Octets, Other> PartialOrd<Opt<Other>> for Opt<Octets>where
Octets: AsRef<[u8]>,
Other: AsRef<[u8]>,
impl<Octets, Other> PartialOrd<Opt<Other>> for Opt<Octets>where
Octets: AsRef<[u8]>,
Other: AsRef<[u8]>,
sourcefn partial_cmp(&self, other: &Opt<Other>) -> Option<Ordering>
fn partial_cmp(&self, other: &Opt<Other>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<Octets> RtypeRecordData for Opt<Octets>
impl<Octets> RtypeRecordData for Opt<Octets>
impl<Octets: AsRef<[u8]>> Eq for Opt<Octets>
Auto Trait Implementations
impl<Octets> RefUnwindSafe for Opt<Octets>where
Octets: RefUnwindSafe,
impl<Octets> Send for Opt<Octets>where
Octets: Send,
impl<Octets> Sync for Opt<Octets>where
Octets: Sync,
impl<Octets> Unpin for Opt<Octets>where
Octets: Unpin,
impl<Octets> UnwindSafe for Opt<Octets>where
Octets: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
sourcefn octets_into(self) -> Result<Target, ShortBuf>
fn octets_into(self) -> Result<Target, ShortBuf>
Performs the conversion.
sourceimpl<Octets, T> ParseRecordData<Octets> for Twhere
T: RtypeRecordData + Parse<Octets> + Compose,
impl<Octets, T> ParseRecordData<Octets> for Twhere
T: RtypeRecordData + Parse<Octets> + Compose,
sourcefn parse_data(
rtype: Rtype,
parser: &mut Parser<Octets>
) -> Result<Option<T>, ParseError>
fn parse_data(
rtype: Rtype,
parser: &mut Parser<Octets>
) -> Result<Option<T>, ParseError>
Parses the record data. Read more