mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
util: add more get_{ref,mut,pin_mut} methods (#3364)
This commit adds: - Framed::get_pin_mut - FramedRead::get_pin_mut - FramedWrite::get_pin_mut - StreamReader::get_ref - StreamReader::get_mut - StreamReader::get_pin_mut - StreamReader::into_inner
This commit is contained in:
@@ -93,6 +93,36 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> StreamReader<S, B> {
|
||||
/// Gets a reference to the underlying stream.
|
||||
///
|
||||
/// It is inadvisable to directly read from the underlying stream.
|
||||
pub fn get_ref(&self) -> &S {
|
||||
&self.inner
|
||||
}
|
||||
|
||||
/// Gets a mutable reference to the underlying stream.
|
||||
///
|
||||
/// It is inadvisable to directly read from the underlying stream.
|
||||
pub fn get_mut(&mut self) -> &mut S {
|
||||
&mut self.inner
|
||||
}
|
||||
|
||||
/// Gets a pinned mutable reference to the underlying stream.
|
||||
///
|
||||
/// It is inadvisable to directly read from the underlying stream.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut S> {
|
||||
self.project().inner
|
||||
}
|
||||
|
||||
/// Consumes this `BufWriter`, returning the underlying stream.
|
||||
///
|
||||
/// Note that any leftover data in the internal buffer is lost.
|
||||
pub fn into_inner(self) -> S {
|
||||
self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B, E> AsyncRead for StreamReader<S, B>
|
||||
where
|
||||
S: Stream<Item = Result<B, E>>,
|
||||
|
||||
Reference in New Issue
Block a user