mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
stream: add inner stream accessors to adaptors (#8272)
This commit is contained in:
@@ -31,6 +31,32 @@ impl<St, F> Filter<St, F> {
|
||||
pub(super) fn new(stream: St, f: F) -> Self {
|
||||
Self { stream, f }
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F> Stream for Filter<St, F>
|
||||
|
||||
@@ -31,6 +31,32 @@ impl<St, F> FilterMap<St, F> {
|
||||
pub(super) fn new(stream: St, f: F) -> Self {
|
||||
Self { stream, f }
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F, T> Stream for FilterMap<St, F>
|
||||
|
||||
@@ -29,6 +29,32 @@ impl<St, F> Map<St, F> {
|
||||
pub(super) fn new(stream: St, f: F) -> Self {
|
||||
Map { stream, f }
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F, T> Stream for Map<St, F>
|
||||
|
||||
@@ -37,6 +37,32 @@ impl<St, F> MapWhile<St, F> {
|
||||
done: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F, T> Stream for MapWhile<St, F>
|
||||
|
||||
@@ -31,6 +31,32 @@ impl<St> Skip<St> {
|
||||
pub(super) fn new(stream: St, remaining: usize) -> Self {
|
||||
Self { stream, remaining }
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St> Stream for Skip<St>
|
||||
|
||||
@@ -34,6 +34,32 @@ impl<St, F> SkipWhile<St, F> {
|
||||
predicate: Some(predicate),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F> Stream for SkipWhile<St, F>
|
||||
|
||||
@@ -32,6 +32,32 @@ impl<St> Take<St> {
|
||||
pub(super) fn new(stream: St, remaining: usize) -> Self {
|
||||
Self { stream, remaining }
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St> Stream for Take<St>
|
||||
|
||||
@@ -37,6 +37,32 @@ impl<St, F> TakeWhile<St, F> {
|
||||
done: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F> Stream for TakeWhile<St, F>
|
||||
|
||||
@@ -38,6 +38,32 @@ impl<St, Fut, F> Then<St, Fut, F> {
|
||||
f,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner stream.
|
||||
pub fn get_ref(&self) -> &St {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_mut(&mut self) -> &mut St {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
/// Returns a pinned mutable reference to the inner stream.
|
||||
///
|
||||
/// Mutating the inner stream may confuse this combinator.
|
||||
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
|
||||
self.project().stream
|
||||
}
|
||||
|
||||
/// Consumes this combinator and returns the inner stream.
|
||||
///
|
||||
/// This may discard intermediate combinator state.
|
||||
pub fn into_inner(self) -> St {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<St, F, Fut> Stream for Then<St, Fut, F>
|
||||
|
||||
Reference in New Issue
Block a user