Struct monoio_codec::Framed
source · pub struct Framed<IO, Codec> { /* private fields */ }
Implementations§
source§impl<IO, Codec> Framed<IO, Codec>
impl<IO, Codec> Framed<IO, Codec>
pub fn new(io: IO, codec: Codec) -> Self
pub fn with_capacity(io: IO, codec: Codec, capacity: usize) -> Self
sourcepub fn get_ref(&self) -> &IO
pub fn get_ref(&self) -> &IO
Returns a reference to the underlying I/O stream wrapped by
Framed
.
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 IO
pub fn get_mut(&mut self) -> &mut IO
Returns a mutable reference to the underlying I/O stream wrapped by
Framed
.
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 codec(&self) -> &Codec
pub fn codec(&self) -> &Codec
Returns a reference to the underlying codec wrapped by
Framed
.
Note that care should be taken to not tamper with the underlying codec as it may corrupt the stream of frames otherwise being worked with.
sourcepub fn codec_mut(&mut self) -> &mut Codec
pub fn codec_mut(&mut self) -> &mut Codec
Returns a mutable reference to the underlying codec wrapped by
Framed
.
Note that care should be taken to not tamper with the underlying codec as it may corrupt the stream of frames otherwise being worked with.
sourcepub fn map_codec<CodecNew, F>(self, map: F) -> Framed<IO, CodecNew>where
F: FnOnce(Codec) -> CodecNew,
pub fn map_codec<CodecNew, F>(self, map: F) -> Framed<IO, CodecNew>where F: FnOnce(Codec) -> CodecNew,
Maps the codec U
to C
, preserving the read and write buffers
wrapped by Framed
.
Note that care should be taken to not tamper with the underlying codec as it may corrupt the stream of frames otherwise being worked with.
sourcepub fn read_buffer(&self) -> &BytesMut
pub fn read_buffer(&self) -> &BytesMut
Returns a reference to the read buffer.
sourcepub fn read_buffer_mut(&mut self) -> &mut BytesMut
pub fn read_buffer_mut(&mut self) -> &mut BytesMut
Returns a mutable reference to the read buffer.
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 into_inner(self) -> IO
pub fn into_inner(self) -> IO
Consumes the Framed
, 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.
Trait Implementations§
source§impl<Codec: Decoder, IO: AsyncReadRent, AnyCodec> NextWithCodec<Codec> for Framed<IO, AnyCodec>
impl<Codec: Decoder, IO: AsyncReadRent, AnyCodec> NextWithCodec<Codec> for Framed<IO, AnyCodec>
type Item = Result<<Codec as Decoder>::Item, <Codec as Decoder>::Error>
type NextFuture<'a> where Self: 'a, Codec: 'a = impl Future<Output = Option<<Framed<IO, AnyCodec> as NextWithCodec<Codec>>::Item>> + 'a
fn next_with<'a>(&'a mut self, codec: &'a mut Codec) -> Self::NextFuture<'_>
source§impl<IO, Codec, Item> Sink<Item> for Framed<IO, Codec>where
IO: AsyncWriteRent,
Codec: Encoder<Item>,
impl<IO, Codec, Item> Sink<Item> for Framed<IO, Codec>where IO: AsyncWriteRent, Codec: Encoder<Item>,
§type Error = <FramedInner<IO, Codec, RWState> as Sink<Item>>::Error
type Error = <FramedInner<IO, Codec, RWState> as Sink<Item>>::Error
§type SendFuture<'a>
where
Self: 'a,
Item: 'a = <FramedInner<IO, Codec, RWState> as Sink<Item>>::SendFuture<'a>
type SendFuture<'a> where Self: 'a, Item: 'a = <FramedInner<IO, Codec, RWState> as Sink<Item>>::SendFuture<'a>
§type FlushFuture<'a>
where
Self: 'a = <FramedInner<IO, Codec, RWState> as Sink<Item>>::FlushFuture<'a>
type FlushFuture<'a> where Self: 'a = <FramedInner<IO, Codec, RWState> as Sink<Item>>::FlushFuture<'a>
§type CloseFuture<'a>
where
Self: 'a = <FramedInner<IO, Codec, RWState> as Sink<Item>>::CloseFuture<'a>
type CloseFuture<'a> where Self: 'a = <FramedInner<IO, Codec, RWState> as Sink<Item>>::CloseFuture<'a>
source§fn send<'a>(&'a mut self, item: Item) -> Self::SendFuture<'a>where
Item: 'a,
fn send<'a>(&'a mut self, item: Item) -> Self::SendFuture<'a>where Item: 'a,
source§fn flush(&mut self) -> Self::FlushFuture<'_>
fn flush(&mut self) -> Self::FlushFuture<'_>
source§fn close(&mut self) -> Self::CloseFuture<'_>
fn close(&mut self) -> Self::CloseFuture<'_>
source§impl<IO, Codec> Stream for Framed<IO, Codec>where
IO: AsyncReadRent,
Codec: Decoder,
impl<IO, Codec> Stream for Framed<IO, Codec>where IO: AsyncReadRent, Codec: Decoder,
§type NextFuture<'a>
where
Self: 'a = <FramedInner<IO, Codec, RWState> as Stream>::NextFuture<'a>
type NextFuture<'a> where Self: 'a = <FramedInner<IO, Codec, RWState> as Stream>::NextFuture<'a>
source§fn next(&mut self) -> Self::NextFuture<'_>
fn next(&mut self) -> Self::NextFuture<'_>
None
if the stream is exhausted.