hyperlane-plugin-websocket 23.2.0

A WebSocket plugin for the Hyperlane framework, providing robust WebSocket communication capabilities and integrating with hyperlane-broadcast for efficient message dissemination.
Documentation
use super::*;

/// Represents the type of broadcast for WebSocket messages.
///
/// This enum allows specifying whether a message is intended for a direct
/// point-to-point communication between two entities or for a group of entities.
///
/// # Type Parameters
///
/// - `T`: The type used to identify points or groups, which must implement `BroadcastTypeTrait`.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum BroadcastType<T: BroadcastTypeTrait> {
    /// Indicates a point-to-point broadcast between two specific entities.
    ///
    /// The tuple contains the identifiers of the two entities involved in the communication.
    PointToPoint(T, T),
    /// Indicates a broadcast to a specific group of entities.
    ///
    /// The tuple contains the identifier of the group.
    PointToGroup(T),
    /// Represents an unknown or unhandled broadcast type.
    ///
    /// This variant is used as a default or fallback for unhandled cases.
    Unknown,
}

/// Outcome of polling one entry from a sparse WebSocket room ring.
pub(crate) enum WsRoomRecv {
    /// One pre-framed RFC 6455 wire message ready to send zero-copy.
    Frame(Arc<[u8]>),
    /// Subscriber lagged behind the bounded ring and advanced to the head.
    Lagged,
    /// The room was closed and no further messages will arrive.
    Closed,
}