pub struct ExtendedError<Octs> { /* private fields */ }
Expand description
Option data for an extended DNS error.
The Extended DNS Error option allows a server to include more detailed
information in a response to a failed query why it did. It contains a
standardized ExtendedErrorCode
for machines and an optional UTF-8
error text for humans.
Implementations§
source§impl<Octs> ExtendedError<Octs>
impl<Octs> ExtendedError<Octs>
sourcepub fn new(
code: ExtendedErrorCode,
text: Option<Str<Octs>>,
) -> Result<Self, LongOptData>
pub fn new( code: ExtendedErrorCode, text: Option<Str<Octs>>, ) -> Result<Self, LongOptData>
Creates a new value from a code and optional text.
Returns an error if text
is present but is too long to fit into
an option.
sourcepub unsafe fn new_unchecked(
code: ExtendedErrorCode,
text: Option<Result<Str<Octs>, Octs>>,
) -> Self
pub unsafe fn new_unchecked( code: ExtendedErrorCode, text: Option<Result<Str<Octs>, Octs>>, ) -> Self
Creates a new value without checking for the option length.
§Safety
The caller must ensure that the length of the wire format of the value does not exceed 65,535 octets.
sourcepub fn code(&self) -> ExtendedErrorCode
pub fn code(&self) -> ExtendedErrorCode
Returns the error code.
sourcepub fn text(&self) -> Option<Result<&Str<Octs>, &Octs>>
pub fn text(&self) -> Option<Result<&Str<Octs>, &Octs>>
Returns the text.
If there is no text, returns None
. If there is text and it is
correctly encoded UTF-8, returns Some(Ok(_))
. If there is text but
it is not UTF-8, returns Some(Err(_))
.
sourcepub fn text_slice(&self) -> Option<&[u8]>
pub fn text_slice(&self) -> Option<&[u8]>
Returns the text as an octets slice.
sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Returns true if the code is in the private range.
pub fn parse<'a, Src: Octets<Range<'a> = Octs> + ?Sized>( parser: &mut Parser<'a, Src>, ) -> Result<Self, ParseError>
Trait Implementations§
source§impl<Octs: Clone> Clone for ExtendedError<Octs>
impl<Octs: Clone> Clone for ExtendedError<Octs>
source§fn clone(&self) -> ExtendedError<Octs>
fn clone(&self) -> ExtendedError<Octs>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<Octs: AsRef<[u8]>> ComposeOptData for ExtendedError<Octs>
impl<Octs: AsRef<[u8]>> ComposeOptData for ExtendedError<Octs>
fn compose_len(&self) -> u16
fn compose_option<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target, ) -> Result<(), Target::AppendError>
source§impl<Octs, Name> From<ExtendedError<Octs>> for AllOptData<Octs, Name>
impl<Octs, Name> From<ExtendedError<Octs>> for AllOptData<Octs, Name>
source§fn from(value: ExtendedError<Octs>) -> Self
fn from(value: ExtendedError<Octs>) -> Self
source§impl<Octs> From<ExtendedErrorCode> for ExtendedError<Octs>
impl<Octs> From<ExtendedErrorCode> for ExtendedError<Octs>
source§fn from(code: ExtendedErrorCode) -> Self
fn from(code: ExtendedErrorCode) -> Self
source§impl<Octs> From<u16> for ExtendedError<Octs>
impl<Octs> From<u16> for ExtendedError<Octs>
source§impl<Octs> OptData for ExtendedError<Octs>
impl<Octs> OptData for ExtendedError<Octs>
source§fn code(&self) -> OptionCode
fn code(&self) -> OptionCode
source§impl<'a, Octs> ParseOptData<'a, Octs> for ExtendedError<Octs::Range<'a>>
impl<'a, Octs> ParseOptData<'a, Octs> for ExtendedError<Octs::Range<'a>>
source§fn parse_option(
code: OptionCode,
parser: &mut Parser<'a, Octs>,
) -> Result<Option<Self>, ParseError>
fn parse_option( code: OptionCode, parser: &mut Parser<'a, Octs>, ) -> Result<Option<Self>, ParseError>
source§impl<Octs, Other> PartialEq<ExtendedError<Other>> for ExtendedError<Octs>
impl<Octs, Other> PartialEq<ExtendedError<Other>> for ExtendedError<Octs>
source§fn eq(&self, other: &ExtendedError<Other>) -> bool
fn eq(&self, other: &ExtendedError<Other>) -> bool
self
and other
values to be equal, and is used
by ==
.