[][src]Struct domain::base::message_builder::StreamTarget

pub struct StreamTarget<Target> { /* fields omitted */ }

A builder target for sending messages on stream transports.

When messages are sent over stream-oriented transports such as TCP, a DNS message is preceded by a 16 bit length value in order to determine the end of a message. This type transparently adds this length value as the first two octets of an octets builder and itself presents an octets builder interface for building the actual message. Whenever data is pushed to that builder interface, the type will update the length value.

Because the length is 16 bits long, the assembled message can be at most 65536 octets long, independently of the maximum length the underlying builder allows.

Implementations

impl<Target: OctetsBuilder> StreamTarget<Target>[src]

pub fn new(target: Target) -> Result<Self, ShortBuf>[src]

Creates a new stream target wrapping an octets builder.

The function will truncate the builder back to empty and appends the length value. Because of the latter, this can fail if the octets builder doesn’t even have space for that.

impl StreamTarget<Vec<u8>>[src]

pub fn new_vec() -> Self[src]

Creates a stream target atop an empty Vec<u8>.

impl<Target: OctetsBuilder> StreamTarget<Target>[src]

pub fn as_target(&self) -> &Target[src]

Returns a reference to the underlying octets builder.

pub fn into_target(self) -> Target[src]

Converts the stream target into the underlying octets builder.

The returned builder will contain the 16 bit length value with the correct content and the assembled message.

pub fn as_stream_slice(&self) -> &[u8][src]

Returns an octets slice of the message for stream transports.

The slice will start with the length octets and can be send as is through a stream transport such as TCP.

pub fn as_dgram_slice(&self) -> &[u8][src]

Returns an octets slice of the message for datagram transports.

The slice will not contain the length octets but only the actual message itself. This slice can be used for sending via datagram transports such as UDP.

Trait Implementations

impl<Target: AsMut<[u8]>> AsMut<[u8]> for StreamTarget<Target>[src]

impl<Target: AsRef<[u8]>> AsRef<[u8]> for StreamTarget<Target>[src]

impl<Target: Clone> Clone for StreamTarget<Target>[src]

impl<Target: Debug> Debug for StreamTarget<Target>[src]

impl<Target: OctetsBuilder> OctetsBuilder for StreamTarget<Target>[src]

Auto Trait Implementations

impl<Target> RefUnwindSafe for StreamTarget<Target> where
    Target: RefUnwindSafe

impl<Target> Send for StreamTarget<Target> where
    Target: Send

impl<Target> Sync for StreamTarget<Target> where
    Target: Sync

impl<Target> Unpin for StreamTarget<Target> where
    Target: Unpin

impl<Target> UnwindSafe for StreamTarget<Target> where
    Target: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,