[−][src]Struct domain::base::message_builder::StreamTarget
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]
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]
fn clone(&self) -> StreamTarget<Target>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Target: Debug> Debug for StreamTarget<Target>
[src]
impl<Target: OctetsBuilder> OctetsBuilder for StreamTarget<Target>
[src]
fn append_slice(&mut self, slice: &[u8]) -> Result<(), ShortBuf>
[src]
fn truncate(&mut self, len: usize)
[src]
fn len(&self) -> usize
[src]
fn is_empty(&self) -> bool
[src]
fn append_all<F>(&mut self, op: F) -> Result<(), ShortBuf> where
F: FnOnce(&mut Self) -> Result<(), ShortBuf>,
[src]
F: FnOnce(&mut Self) -> Result<(), ShortBuf>,
fn append_compressed_dname<N: ToDname>(
&mut self,
name: &N
) -> Result<(), ShortBuf>
[src]
&mut self,
name: &N
) -> Result<(), ShortBuf>
fn u16_len_prefixed<F>(&mut self, op: F) -> Result<(), ShortBuf> where
F: FnOnce(&mut Self) -> Result<(), ShortBuf>,
[src]
F: FnOnce(&mut Self) -> Result<(), ShortBuf>,
Auto Trait Implementations
impl<Target> RefUnwindSafe for StreamTarget<Target> where
Target: RefUnwindSafe,
Target: RefUnwindSafe,
impl<Target> Send for StreamTarget<Target> where
Target: Send,
Target: Send,
impl<Target> Sync for StreamTarget<Target> where
Target: Sync,
Target: Sync,
impl<Target> Unpin for StreamTarget<Target> where
Target: Unpin,
Target: Unpin,
impl<Target> UnwindSafe for StreamTarget<Target> where
Target: UnwindSafe,
Target: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,