Skip to main content

rama_ws/runtime/
mod.rs

1//! Async runtime for Rama WebSockets
2//!
3//! Forked from tokio-tungstenite.
4
5use rama_core::{
6    extensions::ExtensionsRef,
7    futures::{Sink, Stream},
8};
9
10use crate::{Message, ProtocolError};
11
12mod compat;
13mod handshake;
14mod stream;
15
16pub use stream::AsyncWebSocket;
17
18/// A complete asynchronous WebSocket message transport.
19///
20/// This trait gives middleware a protocol-level boundary without coupling it
21/// to [`AsyncWebSocket`] or to the raw byte transport below it. Implementations
22/// can decorate reads and writes while retaining access to connection
23/// extensions.
24pub trait WebSocketIo:
25    Stream<Item = Result<Message, ProtocolError>>
26    + Sink<Message, Error = ProtocolError>
27    + ExtensionsRef
28    + Send
29    + Unpin
30    + 'static
31{
32}
33
34impl<T> WebSocketIo for T where
35    T: Stream<Item = Result<Message, ProtocolError>>
36        + Sink<Message, Error = ProtocolError>
37        + ExtensionsRef
38        + Send
39        + Unpin
40        + 'static
41{
42}