mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-07 00:00:15 +02:00
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:
co-authored by
Loic
loikki
parent
d108c50ce7
commit
221ef3795b
@@ -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>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user