websocket: add a wrapper around is_terminated (#3443)

Co-authored-by: Loic <[email protected]>
Co-authored-by: loikki <[email protected]>
This commit is contained in:
Loic Hausammann
2025-09-28 19:30:07 +02:00
committed by Jonas Platte
co-authored by Loic loikki
parent d108c50ce7
commit 221ef3795b
+8 -1
View File
@@ -96,7 +96,7 @@ use crate::{body::Bytes, response::Response, Error};
use axum_core::body::Body;
use futures_util::{
sink::{Sink, SinkExt},
stream::{Stream, StreamExt},
stream::{FusedStream, Stream, StreamExt},
};
use http::{
header::{self, HeaderMap, HeaderName, HeaderValue},
@@ -533,6 +533,13 @@ impl WebSocket {
}
}
impl FusedStream for WebSocket {
/// Returns true if the websocket has been terminated.
fn is_terminated(&self) -> bool {
self.inner.is_terminated()
}
}
impl Stream for WebSocket {
type Item = Result<Message, Error>;