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 read_state_mut(&mut self) -> (&mut IO, &mut BytesMut)
pub fn read_state_mut(&mut self) -> (&mut IO, &mut BytesMut)
Returns io and 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.
Sourcepub async fn next_with<C: Decoder>(
&mut self,
codec: &mut C,
) -> Option<Result<C::Item, C::Error>>where
IO: AsyncReadRent,
pub async fn next_with<C: Decoder>(
&mut self,
codec: &mut C,
) -> Option<Result<C::Item, C::Error>>where
IO: AsyncReadRent,
Equivalent to Stream::next but with custom codec.