Struct domain::base::message_builder::StreamTarget
source · [−]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
sourceimpl<Target: OctetsBuilder + AsMut<[u8]>> StreamTarget<Target>
impl<Target: OctetsBuilder + AsMut<[u8]>> StreamTarget<Target>
sourceimpl StreamTarget<Vec<u8>>
impl StreamTarget<Vec<u8>>
sourceimpl<Target: OctetsBuilder> StreamTarget<Target>
impl<Target: OctetsBuilder> StreamTarget<Target>
sourcepub fn into_target(self) -> Target
pub fn into_target(self) -> Target
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.
sourceimpl<Target: OctetsBuilder + AsRef<[u8]>> StreamTarget<Target>
impl<Target: OctetsBuilder + AsRef<[u8]>> StreamTarget<Target>
sourcepub fn as_stream_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn as_stream_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
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.
sourcepub fn as_dgram_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn as_dgram_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
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
sourceimpl<Target: Clone> Clone for StreamTarget<Target>
impl<Target: Clone> Clone for StreamTarget<Target>
sourcefn clone(&self) -> StreamTarget<Target>
fn clone(&self) -> StreamTarget<Target>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<Target: Debug> Debug for StreamTarget<Target>
impl<Target: Debug> Debug for StreamTarget<Target>
sourceimpl<Target> OctetsBuilder for StreamTarget<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
impl<Target> OctetsBuilder for StreamTarget<Target>where
Target: OctetsBuilder + AsMut<[u8]>,
type Octets = <Target as OctetsBuilder>::Octets
type Octets = <Target as OctetsBuilder>::Octets
The type of the octets the builder can be converted into. Read more
sourcefn append_slice(&mut self, slice: &[u8]) -> Result<(), ShortBuf>
fn append_slice(&mut self, slice: &[u8]) -> Result<(), ShortBuf>
Appends the content of a slice to the builder. Read more
sourcefn append_all<F>(&mut self, op: F) -> Result<(), ShortBuf>where
F: FnOnce(&mut Self) -> Result<(), ShortBuf>,
fn append_all<F>(&mut self, op: F) -> Result<(), ShortBuf>where
F: FnOnce(&mut Self) -> Result<(), ShortBuf>,
Appends all data or nothing. Read more
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
sourcefn octets_into(self) -> Result<Target, ShortBuf>
fn octets_into(self) -> Result<Target, ShortBuf>
Performs the conversion.