Struct FramedRead
pub struct FramedRead<T, D> { /* private fields */ }
A Stream of messages decoded from an AsyncRead.
For examples of how to use FramedRead with a codec, see the
examples on the codec module.
Cancellation safety
tokio_stream::StreamExt::next: This method is cancel safe. The returned future only holds onto a reference to the underlying stream, so dropping it will never lose a value.
Implementations
impl<T, D> FramedRead<T, D>
fn new(inner: T, decoder: D) -> FramedRead<T, D>Creates a new
FramedReadwith the givendecoder.fn with_capacity(inner: T, decoder: D, capacity: usize) -> FramedRead<T, D>Creates a new
FramedReadwith the givendecoderand a buffer ofcapacityinitial size.fn get_ref(&self) -> &TReturns a reference to the underlying I/O stream wrapped by
FramedRead.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 TReturns a mutable reference to the underlying I/O stream wrapped by
FramedRead.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
FramedRead.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) -> TConsumes the
FramedRead, 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 decoder(&self) -> &DReturns a reference to the underlying decoder.
fn decoder_mut(&mut self) -> &mut DReturns a mutable reference to the underlying decoder.
fn map_decoder<C, F>(self, map: F) -> FramedRead<T, C> where F: FnOnce(D) -> C,Maps the decoder
DtoC, preserving the read buffer wrapped byFramed.fn decoder_pin_mut(self: Pin<&mut Self>) -> &mut DReturns a mutable reference to the underlying decoder.
fn read_buffer(&self) -> &BytesMutReturns a reference to the read buffer.
fn read_buffer_mut(&mut self) -> &mut BytesMutReturns a mutable reference to the read buffer.
fn into_parts(self) -> FramedParts<T, D>Consumes the
FramedRead, returning its underlying I/O stream, the buffer with unprocessed data, and the codec.
Trait Implementations
impl<'__pin, T, D> Unpin for FramedRead<T, D>
where
PinnedFieldsOf<__Origin<'__pin, T, D>>: Unpin,
impl<T, D> Debug for FramedRead<T, D>
where
T: Debug,
D: Debug,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T, D> Stream for FramedRead<T, D>
where
T: AsyncRead,
D: Decoder,
type Item = Result<<D as Decoder>::Item, <D as Decoder>::Error>;fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>
impl<T, I, D> Sink<I> for FramedRead<T, D>
where
T: Sink<I>,
type Error = <T as Sink<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>>
Auto Trait Implementations
impl<T, D> Freeze for FramedRead<T, D>
where
FramedImpl<T, D, ReadFrame>: Freeze,
impl<T, D> RefUnwindSafe for FramedRead<T, D>
where
FramedImpl<T, D, ReadFrame>: RefUnwindSafe,
impl<T, D> Send for FramedRead<T, D>
where
FramedImpl<T, D, ReadFrame>: Send,
impl<T, D> Sync for FramedRead<T, D>
where
FramedImpl<T, D, ReadFrame>: Sync,
impl<T, D> UnsafeUnpin for FramedRead<T, D>
where
FramedImpl<T, D, ReadFrame>: UnsafeUnpin,
impl<T, D> UnwindSafe for FramedRead<T, D>
where
FramedImpl<T, D, ReadFrame>: UnwindSafe,
Blanket Implementations
impl<S, T, E> TryStream for FramedRead<T, D>
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 FramedRead<T, D>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for FramedRead<T, D>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for FramedRead<T, D>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for FramedRead<T, D>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for FramedRead<T, D>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for FramedRead<T, D>
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 FramedRead<T, D>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>