Struct tokio_util::codec::FramedWrite
source · pub struct FramedWrite<T, E> { /* private fields */ }
Expand description
A Sink
of frames encoded to an AsyncWrite
.
For examples of how to use FramedWrite
with a codec, see the
examples on the codec
module.
§Cancellation safety
futures_util::sink::SinkExt::send
: if send is used as the event in atokio::select!
statement and some other branch completes first, then it is guaranteed that the message was not sent, but the message itself is lost.
Implementations§
source§impl<T, E> FramedWrite<T, E>where
T: AsyncWrite,
impl<T, E> FramedWrite<T, E>where
T: AsyncWrite,
sourcepub fn new(inner: T, encoder: E) -> FramedWrite<T, E>
pub fn new(inner: T, encoder: E) -> FramedWrite<T, E>
Creates a new FramedWrite
with the given encoder
.
source§impl<T, E> FramedWrite<T, E>
impl<T, E> FramedWrite<T, E>
sourcepub fn get_ref(&self) -> &T
pub fn get_ref(&self) -> &T
Returns a reference to the underlying I/O stream wrapped by
FramedWrite
.
Note that care should be taken to not tamper with the underlying stream of data coming in as it may corrupt the stream of frames otherwise being worked with.
sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying I/O stream wrapped by
FramedWrite
.
Note that care should be taken to not tamper with the underlying stream of data coming in as it may corrupt the stream of frames otherwise being worked with.
sourcepub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T>
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T>
Returns a pinned mutable reference to the underlying I/O stream wrapped by
FramedWrite
.
Note that care should be taken to not tamper with the underlying stream of data coming in as it may corrupt the stream of frames otherwise being worked with.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the FramedWrite
, returning its underlying I/O stream.
Note that care should be taken to not tamper with the underlying stream of data coming in as it may corrupt the stream of frames otherwise being worked with.
sourcepub fn encoder_mut(&mut self) -> &mut E
pub fn encoder_mut(&mut self) -> &mut E
Returns a mutable reference to the underlying encoder.
sourcepub fn map_encoder<C, F>(self, map: F) -> FramedWrite<T, C>where
F: FnOnce(E) -> C,
pub fn map_encoder<C, F>(self, map: F) -> FramedWrite<T, C>where
F: FnOnce(E) -> C,
Maps the encoder E
to C
, preserving the write buffer
wrapped by Framed
.
sourcepub fn encoder_pin_mut(self: Pin<&mut Self>) -> &mut E
pub fn encoder_pin_mut(self: Pin<&mut Self>) -> &mut E
Returns a mutable reference to the underlying encoder.
sourcepub fn write_buffer(&self) -> &BytesMut
pub fn write_buffer(&self) -> &BytesMut
Returns a reference to the write buffer.
sourcepub fn write_buffer_mut(&mut self) -> &mut BytesMut
pub fn write_buffer_mut(&mut self) -> &mut BytesMut
Returns a mutable reference to the write buffer.
sourcepub fn backpressure_boundary(&self) -> usize
pub fn backpressure_boundary(&self) -> usize
Returns backpressure boundary
sourcepub fn set_backpressure_boundary(&mut self, boundary: usize)
pub fn set_backpressure_boundary(&mut self, boundary: usize)
Updates backpressure boundary
Trait Implementations§
source§impl<T, U> Debug for FramedWrite<T, U>
impl<T, U> Debug for FramedWrite<T, U>
source§impl<T, I, E> Sink<I> for FramedWrite<T, E>
impl<T, I, E> Sink<I> for FramedWrite<T, E>
source§type Error = <E as Encoder<I>>::Error
type Error = <E as Encoder<I>>::Error
source§fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Sink
to receive a value. Read moresource§fn start_send(self: Pin<&mut Self>, item: I) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: I) -> Result<(), Self::Error>
poll_ready
which returned Poll::Ready(Ok(()))
. Read more