Struct FramedWrite

pub struct FramedWrite<T, E> { /* private fields */ }

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

Implementations

impl<T, E> FramedWrite<T, E>

fn new(inner: T, encoder: E) -> FramedWrite<T, E>

Creates a new FramedWrite with the given encoder.

fn with_capacity(inner: T, encoder: E, capacity: usize) -> FramedWrite<T, E>

Creates a new FramedWrite with the given encoder and a buffer of capacity initial size.

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.

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.

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.

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.

fn encoder(&self) -> &E

Returns a reference to the underlying encoder.

fn encoder_mut(&mut self) -> &mut E

Returns a mutable reference to the underlying encoder.

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.

fn encoder_pin_mut(self: Pin<&mut Self>) -> &mut E

Returns a mutable reference to the underlying encoder.

fn write_buffer(&self) -> &BytesMut

Returns a reference to the write buffer.

fn write_buffer_mut(&mut self) -> &mut BytesMut

Returns a mutable reference to the write buffer.

fn backpressure_boundary(&self) -> usize

Returns backpressure boundary

fn set_backpressure_boundary(&mut self, boundary: usize)

Updates backpressure boundary

fn into_parts(self) -> FramedParts<T, E>

Consumes the FramedWrite, returning its underlying I/O stream, the buffer with unprocessed data, and the codec.

Trait Implementations

impl<'__pin, T, E> Unpin for FramedWrite<T, E> where PinnedFieldsOf<__Origin<'__pin, T, E>>: Unpin,

impl<T, D> Stream for FramedWrite<T, D> where T: Stream,

type Item = <T as Stream>::Item;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>

impl<T, I, E> Sink<I> for FramedWrite<T, E> where T: AsyncWrite, E: Encoder<I>, E::Error: From<Error>,

type Error = <E as Encoder<I>>::Error;
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn start_send(self: Pin<&mut Self>, item: I) -> Result<(), Self::Error>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

impl<T, U> Debug for FramedWrite<T, U> where T: Debug, U: Debug,

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<T, E> Freeze for FramedWrite<T, E> where FramedImpl<T, E, WriteFrame>: Freeze,

impl<T, E> RefUnwindSafe for FramedWrite<T, E> where FramedImpl<T, E, WriteFrame>: RefUnwindSafe,

impl<T, E> Send for FramedWrite<T, E> where FramedImpl<T, E, WriteFrame>: Send,

impl<T, E> Sync for FramedWrite<T, E> where FramedImpl<T, E, WriteFrame>: Sync,

impl<T, E> UnsafeUnpin for FramedWrite<T, E> where FramedImpl<T, E, WriteFrame>: UnsafeUnpin,

impl<T, E> UnwindSafe for FramedWrite<T, E> where FramedImpl<T, E, WriteFrame>: UnwindSafe,

Blanket Implementations

impl<S, T, E> TryStream for FramedWrite<T, E> where S: Stream<Item = Result<T, E>> + ?Sized,

type Ok = T;
type Error = E;
fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>

impl<T> Any for FramedWrite<T, E> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for FramedWrite<T, E> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for FramedWrite<T, E> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for FramedWrite<T, E>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for FramedWrite<T, E> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for FramedWrite<T, E> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for FramedWrite<T, E> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>