aboutsummaryrefslogtreecommitdiff
path: root/src/stream/try_stream/inspect_err.rs
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-05-08 19:26:17 -0700
committerChih-Hung Hsieh <chh@google.com>2020-05-11 21:06:51 -0700
commit52627c866ba9ce070950c81a3a98f844a55305cf (patch)
treeb261d9acf1a15a6d9d39e311930effa8fdaccd43 /src/stream/try_stream/inspect_err.rs
parent032d3071c35e3fc8fd539889f96691b67d489bbb (diff)
downloadfutures-util-52627c866ba9ce070950c81a3a98f844a55305cf.tar.gz
Upgrade rust/crates/futures-util to 0.3.5
* Update Android.bp with new features and dependent packages for futures-* 0.3.5. * New dependencies of pin-project and pin-project-internal. Test: mm in external/rust/crates Change-Id: I705a08e44c8598d28b4b465170df8ed206df1494
Diffstat (limited to 'src/stream/try_stream/inspect_err.rs')
-rw-r--r--src/stream/try_stream/inspect_err.rs118
1 files changed, 0 insertions, 118 deletions
diff --git a/src/stream/try_stream/inspect_err.rs b/src/stream/try_stream/inspect_err.rs
deleted file mode 100644
index 3c23ae0..0000000
--- a/src/stream/try_stream/inspect_err.rs
+++ /dev/null
@@ -1,118 +0,0 @@
-use crate::stream::stream::inspect;
-use core::fmt;
-use core::pin::Pin;
-use futures_core::stream::{FusedStream, Stream, TryStream};
-use futures_core::task::{Context, Poll};
-#[cfg(feature = "sink")]
-use futures_sink::Sink;
-use pin_utils::{unsafe_pinned, unsafe_unpinned};
-
-/// Stream for the [`inspect_err`](super::TryStreamExt::inspect_err) method.
-#[must_use = "streams do nothing unless polled"]
-pub struct InspectErr<St, F> {
- stream: St,
- f: F,
-}
-
-impl<St: Unpin, F> Unpin for InspectErr<St, F> {}
-
-impl<St, F> fmt::Debug for InspectErr<St, F>
-where
- St: fmt::Debug,
-{
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.debug_struct("InspectErr")
- .field("stream", &self.stream)
- .finish()
- }
-}
-
-impl<St, F> InspectErr<St, F> {
- unsafe_pinned!(stream: St);
- unsafe_unpinned!(f: F);
-}
-
-impl<St, F> InspectErr<St, F>
-where
- St: TryStream,
- F: FnMut(&St::Error),
-{
- pub(super) fn new(stream: St, f: F) -> Self {
- Self { stream, f }
- }
-
- /// Acquires a reference to the underlying stream that this combinator is
- /// pulling from.
- pub fn get_ref(&self) -> &St {
- &self.stream
- }
-
- /// Acquires a mutable reference to the underlying stream that this
- /// combinator is pulling from.
- ///
- /// Note that care must be taken to avoid tampering with the state of the
- /// stream which may otherwise confuse this combinator.
- pub fn get_mut(&mut self) -> &mut St {
- &mut self.stream
- }
-
- /// Acquires a pinned mutable reference to the underlying stream that this
- /// combinator is pulling from.
- ///
- /// Note that care must be taken to avoid tampering with the state of the
- /// stream which may otherwise confuse this combinator.
- pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
- self.stream()
- }
-
- /// Consumes this combinator, returning the underlying stream.
- ///
- /// Note that this may discard intermediate state of this combinator, so
- /// care should be taken to avoid losing resources when this is called.
- pub fn into_inner(self) -> St {
- self.stream
- }
-}
-
-impl<St, F> FusedStream for InspectErr<St, F>
-where
- St: TryStream + FusedStream,
- F: FnMut(&St::Error),
-{
- fn is_terminated(&self) -> bool {
- self.stream.is_terminated()
- }
-}
-
-impl<St, F> Stream for InspectErr<St, F>
-where
- St: TryStream,
- F: FnMut(&St::Error),
-{
- type Item = Result<St::Ok, St::Error>;
-
- fn poll_next(
- mut self: Pin<&mut Self>,
- cx: &mut Context<'_>,
- ) -> Poll<Option<Self::Item>> {
- self.as_mut()
- .stream()
- .try_poll_next(cx)
- .map(|opt| opt.map(|res| res.map_err(|e| inspect(e, self.as_mut().f()))))
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- self.stream.size_hint()
- }
-}
-
-// Forwarding impl of Sink from the underlying stream
-#[cfg(feature = "sink")]
-impl<S, F, Item> Sink<Item> for InspectErr<S, F>
-where
- S: Sink<Item>,
-{
- type Error = S::Error;
-
- delegate_sink!(stream, Item);
-}