Skip to main content

ws_bridge/
lib.rs

1mod codec;
2mod connection;
3
4pub use codec::{DecodeError, EncodeError, NoMessages, WsCodec, WsMessage};
5pub use connection::{RecvError, SendError, WsConnection, WsReceiver, WsSender};
6
7#[cfg(feature = "server")]
8pub mod server;
9
10#[cfg(feature = "yew-client")]
11pub mod yew_client;
12
13#[cfg(feature = "native-client")]
14pub mod native_client;
15
16#[cfg(feature = "reconnect")]
17pub mod reconnect;
18
19/// Defines a WebSocket endpoint — its path, and the message types
20/// that flow in each direction.
21///
22/// Implement this on a unit struct in your shared crate. That struct
23/// becomes the single source of truth for the endpoint, usable by
24/// server, browser client, and native client alike.
25pub trait WsEndpoint {
26    /// The URL path for this endpoint (e.g., "/ws/session").
27    const PATH: &'static str;
28
29    /// Messages sent FROM the server TO the client.
30    type ServerMsg: WsCodec + Clone + Send + 'static;
31
32    /// Messages sent FROM the client TO the server.
33    type ClientMsg: WsCodec + Clone + Send + 'static;
34}