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