pub struct StreamTarget<Target> { /* private fields */ }
Expand description

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

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.

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

Returns a reference to the underlying octets builder.

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.

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.

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

Converts this type into a mutable reference of the (usually inferred) input type.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The type of the octets the builder can be converted into. Read more

Appends the content of a slice to the builder. Read more

Truncates the builder back to a length of len octets.

Converts the builder into immutable octets.

Returns the length of the already assembled data.

Returns whether the builder is currently empty.

Appends all data or nothing. Read more

Appends a domain name using name compression if supported. Read more

Prepends some appended data with its length as a u16. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.