]>
git.proxmox.com Git - rustc.git/blob - vendor/futures-util/src/stream/stream/fuse.rs
2 use futures_core
::ready
;
3 use futures_core
::stream
::{FusedStream, Stream}
;
4 use futures_core
::task
::{Context, Poll}
;
5 #[cfg(feature = "sink")]
6 use futures_sink
::Sink
;
7 use pin_project_lite
::pin_project
;
10 /// Stream for the [`fuse`](super::StreamExt::fuse) method.
12 #[must_use = "streams do nothing unless polled"]
21 pub(super) fn new(stream
: St
) -> Self {
22 Self { stream, done: false }
25 /// Returns whether the underlying stream has finished or not.
27 /// If this method returns `true`, then all future calls to poll are
28 /// guaranteed to return `None`. If this returns `false`, then the
29 /// underlying stream is still in use.
30 pub fn is_done(&self) -> bool
{
34 delegate_access_inner
!(stream
, St
, ());
37 impl<S
: Stream
> FusedStream
for Fuse
<S
> {
38 fn is_terminated(&self) -> bool
{
43 impl<S
: Stream
> Stream
for Fuse
<S
> {
46 fn poll_next(self: Pin
<&mut Self>, cx
: &mut Context
<'_
>) -> Poll
<Option
<S
::Item
>> {
47 let this
= self.project();
50 return Poll
::Ready(None
);
53 let item
= ready
!(this
.stream
.poll_next(cx
));
60 fn size_hint(&self) -> (usize, Option
<usize>) {
64 self.stream
.size_hint()
69 // Forwarding impl of Sink from the underlying stream
70 #[cfg(feature = "sink")]
71 impl<S
: Stream
+ Sink
<Item
>, Item
> Sink
<Item
> for Fuse
<S
> {
72 type Error
= S
::Error
;
74 delegate_sink
!(stream
, Item
);