Skip to main content

ExtendedError

Struct ExtendedError 

Source
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>

Source

pub fn new( code: ExtendedErrorCode, text: Option<Str<Octs>>, ) -> Result<ExtendedError<Octs>, LongOptData>
where Octs: AsRef<[u8]>,

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.

Source

pub fn new_with_str( code: ExtendedErrorCode, text: &str, ) -> Result<ExtendedError<Octs>, LongOptData>

Source

pub unsafe fn new_unchecked( code: ExtendedErrorCode, text: Option<Result<Str<Octs>, Octs>>, ) -> ExtendedError<Octs>

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.

Source

pub fn code(&self) -> ExtendedErrorCode

Returns the error code.

Source

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(_)).

Source

pub fn text_slice(&self) -> Option<&[u8]>
where Octs: AsRef<[u8]>,

Returns the text as an octets slice.

Source

pub fn set_text(&mut self, text: Str<Octs>)

Sets the text field.

Source

pub fn is_private(&self) -> bool

Returns true if the code is in the private range.

Source

pub fn parse<'a, Src>( parser: &mut Parser<'a, Src>, ) -> Result<ExtendedError<Octs>, ParseError>
where Src: Octets<Range<'a> = Octs> + ?Sized, Octs: AsRef<[u8]>,

Trait Implementations§

Source§

impl<Octs> Clone for ExtendedError<Octs>
where Octs: Clone,

Source§

fn clone(&self) -> ExtendedError<Octs>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Octs> ComposeOptData for ExtendedError<Octs>
where Octs: AsRef<[u8]>,

Source§

fn compose_len(&self) -> u16

Source§

fn compose_option<Target>( &self, target: &mut Target, ) -> Result<(), <Target as OctetsBuilder>::AppendError>
where Target: OctetsBuilder + ?Sized,

Source§

impl<Octs> Debug for ExtendedError<Octs>
where Octs: AsRef<[u8]>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<Octs> Display for ExtendedError<Octs>
where Octs: AsRef<[u8]>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<Octs> Eq for ExtendedError<Octs>
where Octs: AsRef<[u8]>,

Source§

impl<Octs, Name> From<ExtendedError<Octs>> for AllOptData<Octs, Name>

Source§

fn from(value: ExtendedError<Octs>) -> AllOptData<Octs, Name>

Converts to this type from the input type.
Source§

impl<Octs> From<ExtendedErrorCode> for ExtendedError<Octs>

Source§

fn from(code: ExtendedErrorCode) -> ExtendedError<Octs>

Converts to this type from the input type.
Source§

impl<Octs> From<u16> for ExtendedError<Octs>

Source§

fn from(code: u16) -> ExtendedError<Octs>

Converts to this type from the input type.
Source§

impl<Octs> Hash for ExtendedError<Octs>
where Octs: AsRef<[u8]>,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Octs, SrcOcts> OctetsFrom<ExtendedError<SrcOcts>> for ExtendedError<Octs>
where Octs: OctetsFrom<SrcOcts>,

Source§

type Error = <Octs as OctetsFrom<SrcOcts>>::Error

Source§

fn try_octets_from( source: ExtendedError<SrcOcts>, ) -> Result<ExtendedError<Octs>, <ExtendedError<Octs> as OctetsFrom<ExtendedError<SrcOcts>>>::Error>

Performs the conversion.
Source§

fn octets_from(source: Source) -> Self
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<Octs> OptData for ExtendedError<Octs>

Source§

fn code(&self) -> OptionCode

Returns the option code associated with this option.
Source§

impl<'a, Octs> ParseOptData<'a, Octs> for ExtendedError<<Octs as Octets>::Range<'a>>
where Octs: Octets + ?Sized,

Source§

fn parse_option( code: OptionCode, parser: &mut Parser<'a, Octs>, ) -> Result<Option<ExtendedError<<Octs as Octets>::Range<'a>>>, ParseError>

Parses the option code data. Read more
Source§

impl<Octs, Other> PartialEq<ExtendedError<Other>> for ExtendedError<Octs>
where Octs: AsRef<[u8]>, Other: AsRef<[u8]>,

Source§

fn eq(&self, other: &ExtendedError<Other>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Octs> TryFrom<(ExtendedErrorCode, Str<Octs>)> for ExtendedError<Octs>
where Octs: AsRef<[u8]>,

Source§

type Error = LongOptData

The type returned in the event of a conversion error.
Source§

fn try_from( _: (ExtendedErrorCode, Str<Octs>), ) -> Result<ExtendedError<Octs>, <ExtendedError<Octs> as TryFrom<(ExtendedErrorCode, Str<Octs>)>>::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<Octs> Freeze for ExtendedError<Octs>
where Octs: Freeze,

§

impl<Octs> RefUnwindSafe for ExtendedError<Octs>
where Octs: RefUnwindSafe,

§

impl<Octs> Send for ExtendedError<Octs>
where Octs: Send,

§

impl<Octs> Sync for ExtendedError<Octs>
where Octs: Sync,

§

impl<Octs> Unpin for ExtendedError<Octs>
where Octs: Unpin,

§

impl<Octs> UnsafeUnpin for ExtendedError<Octs>
where Octs: UnsafeUnpin,

§

impl<Octs> UnwindSafe for ExtendedError<Octs>
where Octs: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.