Struct FramedWrite

Source
pub struct FramedWrite<IO, Codec> { /* private fields */ }

Implementations§

Source§

impl<IO, Codec> FramedWrite<IO, Codec>

Source

pub fn new(io: IO, encoder: Codec) -> Self

Source

pub fn get_ref(&self) -> &IO

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.

Source

pub fn get_mut(&mut self) -> &mut IO

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.

Source

pub fn into_inner(self) -> IO

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.

Source

pub fn encoder(&self) -> &Codec

Returns a reference to the underlying encoder.

Source

pub fn encoder_mut(&mut self) -> &mut Codec

Returns a mutable reference to the underlying encoder.

Source

pub fn map_encoder<CodecNew, F>(self, map: F) -> FramedWrite<IO, CodecNew>
where F: FnOnce(Codec) -> CodecNew,

Maps the encoder E to C, preserving the write buffer wrapped by Framed.

Source

pub fn write_buffer(&self) -> &BytesMut

Returns a reference to the write buffer.

Source

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

Returns a mutable reference to the write buffer.

Trait Implementations§

Source§

impl<IO: AsyncWriteRent, Codec> AsyncWriteRent for FramedWrite<IO, Codec>

Source§

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Same as write(2)
Source§

async fn writev<T: IoVecBuf>(&mut self, buf_vec: T) -> BufResult<usize, T>

Same as writev(2)
Source§

async fn flush(&mut self) -> Result<()>

Flush buffered data if needed
Source§

async fn shutdown(&mut self) -> Result<()>

Same as shutdown
Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<IO, Codec, Item> Sink<Item> for FramedWrite<IO, Codec>
where IO: AsyncWriteRent, Codec: Encoder<Item>,

Source§

type Error = <FramedInner<IO, Codec, WriteState> as Sink<Item>>::Error

The type of value produced by the sink when an error occurs.
Source§

async fn send(&mut self, item: Item) -> Result<(), Self::Error>

Send item.
Source§

async fn flush(&mut self) -> Result<(), Self::Error>

Flush any remaining output from this sink.
Source§

async fn close(&mut self) -> Result<(), Self::Error>

Flush any remaining output and close this sink, if necessary.
Source§

impl<Codec: Encoder<Item>, IO: AsyncWriteRent, AnyCodec, Item> SinkWithCodec<Codec, Item> for FramedWrite<IO, AnyCodec>

Source§

async fn send_with<'a>( &'a mut self, codec: &'a mut Codec, item: Item, ) -> Result<(), Codec::Error>

Source§

async fn flush(&mut self) -> Result<(), Codec::Error>

Auto Trait Implementations§

§

impl<IO, Codec> Freeze for FramedWrite<IO, Codec>
where IO: Freeze, Codec: Freeze,

§

impl<IO, Codec> RefUnwindSafe for FramedWrite<IO, Codec>
where IO: RefUnwindSafe, Codec: RefUnwindSafe,

§

impl<IO, Codec> Send for FramedWrite<IO, Codec>
where IO: Send, Codec: Send,

§

impl<IO, Codec> Sync for FramedWrite<IO, Codec>
where IO: Sync, Codec: Sync,

§

impl<IO, Codec> Unpin for FramedWrite<IO, Codec>
where IO: Unpin, Codec: Unpin,

§

impl<IO, Codec> UnwindSafe for FramedWrite<IO, Codec>
where IO: UnwindSafe, Codec: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<A> AsyncWriteRentExt for A
where A: AsyncWriteRent + ?Sized,

Source§

async fn write_all<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoBuf + 'static,

Write all
Source§

async fn write_vectored_all<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoVecBuf + 'static,

Write vectored all
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, A> SinkExt<T> for A
where A: Sink<T>,

Source§

async fn send_and_flush(&mut self, item: T) -> Result<(), <A as Sink<T>>::Error>

Send and flush.
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.