domain::base::wire

Trait Composer

Source
pub trait Composer:
    OctetsBuilder
    + AsRef<[u8]>
    + AsMut<[u8]>
    + Truncate {
    // Provided methods
    fn append_compressed_dname<N: ToDname + ?Sized>(
        &mut self,
        name: &N,
    ) -> Result<(), Self::AppendError> { ... }
    fn can_compress(&self) -> bool { ... }
}

Provided Methods§

Source

fn append_compressed_dname<N: ToDname + ?Sized>( &mut self, name: &N, ) -> Result<(), Self::AppendError>

Appends a domain name using name compression if supported.

Domain name compression attempts to lower the size of a DNS message by avoiding to include repeated domain name suffixes. Instead of adding the full suffix, a pointer to the location of the previous occurence is added. Since that occurence may itself contain a compressed suffix, doing name compression isn’t cheap and therefore optional. However, in order to be able to opt in, we need to know if we are dealing with a domain name that ought to be compressed.

The trait provides a default implementation which simply appends the name uncompressed.

Source

fn can_compress(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Composer for BytesMut

Source§

impl Composer for Vec<u8>

Source§

impl<A: Array<Item = u8>> Composer for SmallVec<A>

Source§

impl<T: Composer> Composer for &mut T

Source§

fn append_compressed_dname<N: ToDname + ?Sized>( &mut self, name: &N, ) -> Result<(), Self::AppendError>

Source§

fn can_compress(&self) -> bool

Source§

impl<const N: usize> Composer for Array<N>

Implementors§

Source§

impl<Target> Composer for StreamTarget<Target>
where Target: Composer, Target::AppendError: Into<ShortBuf>,

Source§

impl<Target: Composer> Composer for StaticCompressor<Target>

Source§

impl<Target: Composer> Composer for TreeCompressor<Target>