From 38bfaa4f10f64ce79d22fa2238cfe707bc1c4346 Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Tue, 22 Mar 2022 18:13:21 +0100 Subject: [PATCH] Implement the `FusedStream` along with `Stream` --- src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f6919ce..73458db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ use compat::{cvt, AllowStd, ContextWaker}; use futures_io::{AsyncRead, AsyncWrite}; use futures_util::{ sink::{Sink, SinkExt}, - stream::Stream, + stream::{FusedStream, Stream}, }; use log::*; use std::pin::Pin; @@ -343,6 +343,15 @@ where } } +impl FusedStream for WebSocketStream +where + T: AsyncRead + AsyncWrite + Unpin, +{ + fn is_terminated(&self) -> bool { + self.ended + } +} + impl Sink for WebSocketStream where T: AsyncRead + AsyncWrite + Unpin,