Skip to content

Commit e43030d

Browse files
loikkiLoicloikki
authored
websocket: add a wrapper around is_terminated (#3443)
Co-authored-by: Loic <[email protected]> Co-authored-by: loikki <[email protected]>
1 parent ab593bb commit e43030d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

axum/src/extract/ws.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ use self::rejection::*;
9494
use super::FromRequestParts;
9595
use crate::{body::Bytes, response::Response, Error};
9696
use axum_core::body::Body;
97-
use futures_core::Stream;
97+
use futures_core::{FusedStream, Stream};
9898
use futures_sink::Sink;
9999
use futures_util::{sink::SinkExt, stream::StreamExt};
100100
use http::{
@@ -530,6 +530,13 @@ impl WebSocket {
530530
}
531531
}
532532

533+
impl FusedStream for WebSocket {
534+
/// Returns true if the websocket has been terminated.
535+
fn is_terminated(&self) -> bool {
536+
self.inner.is_terminated()
537+
}
538+
}
539+
533540
impl Stream for WebSocket {
534541
type Item = Result<Message, Error>;
535542

0 commit comments

Comments
 (0)