Skip to main content

Padding

Struct Padding 

Source
pub struct Padding<Octs>
where Octs: ?Sized,
{ /* private fields */ }
Expand description

Option data for the padding option.

This option is used to increase the size of a DNS message to a fixed value so eavesdropper can’t dertermine information from the size.

Generally, you should not need to use this type. Instead, you can use the OptBuilder::padding and [OptBuilder::random_padding] methods to add padding to a message – and ignore it when receving one.

The option is defined in RFC 7830.

Implementations§

Source§

impl Padding<()>

Source

pub const CODE: OptionCode = OptionCode::PADDING

The option code for this option.

Source§

impl<Octs> Padding<Octs>

Source

pub fn from_octets(octets: Octs) -> Result<Padding<Octs>, LongOptData>
where Octs: AsRef<[u8]>,

Creates a value from the padding octets.

Returns an error if octets are longer than 65,535 octets.

Source

pub unsafe fn from_octets_unchecked(octets: Octs) -> Padding<Octs>

Creates a value from the padding octets without checking.

§Safety

The caller needs to ensure that octets are not longer than 65,535 octets.

Source

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

Parses a value from its wire formal.

Source§

impl<Octs> Padding<Octs>
where Octs: ?Sized,

Source

pub fn as_octets(&self) -> &Octs

Returns a reference to the padding octets.

Source

pub fn into_octets(self) -> Octs
where Octs: Sized,

Converts the value into the padding octets.

Source

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

Returns a slice of the padding octets.

Trait Implementations§

Source§

impl<Octs> AsRef<[u8]> for Padding<Octs>
where Octs: AsRef<[u8]> + ?Sized,

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Octs> Borrow<[u8]> for Padding<Octs>
where Octs: AsRef<[u8]> + ?Sized,

Source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
Source§

impl<Octs> Clone for Padding<Octs>
where Octs: Clone + ?Sized,

Source§

fn clone(&self) -> Padding<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 Padding<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> Copy for Padding<Octs>
where Octs: Copy + ?Sized,

Source§

impl<Octs> Debug for Padding<Octs>
where Octs: AsRef<[u8]> + ?Sized,

Source§

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

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

impl<Octs> Display for Padding<Octs>
where Octs: AsRef<[u8]> + ?Sized,

Source§

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

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

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Source§

fn try_octets_from( src: Padding<SrcOcts>, ) -> Result<Padding<Octs>, <Padding<Octs> as OctetsFrom<Padding<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 Padding<Octs>

Source§

fn code(&self) -> OptionCode

Returns the option code associated with this option.
Source§

impl<'a, Octs> ParseOptData<'a, Octs> for Padding<<Octs as Octets>::Range<'a>>
where Octs: Octets,

Source§

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

Parses the option code data. Read more

Auto Trait Implementations§

§

impl<Octs> Freeze for Padding<Octs>
where Octs: Freeze + ?Sized,

§

impl<Octs> RefUnwindSafe for Padding<Octs>
where Octs: RefUnwindSafe + ?Sized,

§

impl<Octs> Send for Padding<Octs>
where Octs: Send + ?Sized,

§

impl<Octs> Sync for Padding<Octs>
where Octs: Sync + ?Sized,

§

impl<Octs> Unpin for Padding<Octs>
where Octs: Unpin + ?Sized,

§

impl<Octs> UnsafeUnpin for Padding<Octs>
where Octs: UnsafeUnpin + ?Sized,

§

impl<Octs> UnwindSafe for Padding<Octs>
where Octs: UnwindSafe + ?Sized,

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.