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-16 15:54:44 +00:00
committed by GitHub
co-authored by Loic loikki
parent ab593bbab7
commit e43030d051
+8 -1
View File
@@ -94,7 +94,7 @@ use self::rejection::*;
use super::FromRequestParts;
use crate::{body::Bytes, response::Response, Error};
use axum_core::body::Body;
use futures_core::Stream;
use futures_core::{FusedStream, Stream};
use futures_sink::Sink;
use futures_util::{sink::SinkExt, stream::StreamExt};
use http::{
@@ -530,6 +530,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>;