Skip to main content

hyperlane_plugin_websocket/
enum.rs

1use super::*;
2
3/// Represents the type of broadcast for WebSocket messages.
4///
5/// This enum allows specifying whether a message is intended for a direct
6/// point-to-point communication between two entities or for a group of entities.
7///
8/// # Type Parameters
9///
10/// - `T`: The type used to identify points or groups, which must implement `BroadcastTypeTrait`.
11#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
12pub enum BroadcastType<T: BroadcastTypeTrait> {
13    /// Indicates a point-to-point broadcast between two specific entities.
14    ///
15    /// The tuple contains the identifiers of the two entities involved in the communication.
16    PointToPoint(T, T),
17    /// Indicates a broadcast to a specific group of entities.
18    ///
19    /// The tuple contains the identifier of the group.
20    PointToGroup(T),
21    /// Represents an unknown or unhandled broadcast type.
22    ///
23    /// This variant is used as a default or fallback for unhandled cases.
24    Unknown,
25}
26
27/// Outcome of polling one entry from a sparse WebSocket room ring.
28pub(crate) enum WsRoomRecv {
29    /// One pre-framed RFC 6455 wire message ready to send zero-copy.
30    Frame(Arc<[u8]>),
31    /// Subscriber lagged behind the bounded ring and advanced to the head.
32    Lagged,
33    /// The room was closed and no further messages will arrive.
34    Closed,
35}