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
/// Pre-concatenated point-to-point key prefix including the trailing separator hyphen.
pub(crate) const POINT_TO_POINT_PREFIX: &str = "ptp--";

/// Pre-concatenated point-to-group key prefix including the trailing separator hyphen.
pub(crate) const POINT_TO_GROUP_PREFIX: &str = "ptg--";

/// Stack buffer capacity in bytes for formatting broadcast room keys without heap allocation.
pub(crate) const STACK_KEY_BUF_LEN: usize = 64;

/// ASCII hyphen separator byte used in broadcast keys and negative integers.
pub(crate) const BYTE_DASH: u8 = b'-';

/// ASCII zero digit byte.
pub(crate) const BYTE_ZERO: u8 = b'0';

/// Lowercase ASCII representation of `true`.
pub(crate) const BOOL_TRUE_BYTES: &[u8] = b"true";

/// Lowercase ASCII representation of `false`.
pub(crate) const BOOL_FALSE_BYTES: &[u8] = b"false";

/// Two-digit ASCII decimal lookup pairs for `00..=99`.
pub(crate) const DEC_DIGITS_LUT: &[u8; 200] = b"00010203040506070809\
10111213141516171819\
20212223242526272829\
30313233343536373839\
40414243444546474849\
50515253545556575859\
60616263646566676869\
70717273747576777879\
80818283848586878889\
90919293949596979899";

/// Maximum coalesced broadcast frame bytes accumulated per single stream write.
pub(crate) const WS_COALESCE_MAX_BYTES: usize = 64 * 1024;

/// Maximum reusable heap buffer capacity retained in the worker-local coalesce scratch pool.
pub(crate) const WS_FRAME_BUF_MAX_RETAIN: usize = 64 * 1024;

/// Maximum number of reusable frame coalesce buffers cached per worker thread.
pub(crate) const WS_MAX_POOLED_COALESCE_BUFS: usize = 16;

/// Stack buffer capacity in bytes for single-allocation server WebSocket frame encoding.
pub(crate) const WS_FRAME_STACK_CAP: usize = 512;

/// Number of cache-line-aligned room shards in [`SparseWsHub`].
pub(crate) const WS_SHARD_COUNT: usize = 64;

/// Multiplicative 64-bit mixing constant for zero-allocation [`WsKeyHasher`].
pub(crate) const WS_FX_HASH_K: u64 = 0x517c_c1b7_2722_0a95;

/// Prebuilt RFC 6455 empty final text frame (`FIN=1, opcode=Text, len=0`).
pub(crate) const WS_EMPTY_TEXT_FRAME: [u8; 2] = [0x81, 0x00];

/// RFC 6455 `FIN` bit flag (`0x80`).
pub(crate) const WS_FIN_BIT: u8 = 0x80;

/// RFC 6455 continuation frame opcode (`0x00`).
pub(crate) const WS_OPCODE_CONTINUATION: u8 = 0x00;

/// RFC 6455 text frame opcode (`0x01`).
pub(crate) const WS_OPCODE_TEXT: u8 = 0x01;

/// RFC 6455 binary frame opcode (`0x02`).
pub(crate) const WS_OPCODE_BINARY: u8 = 0x02;

/// RFC 6455 UTF-8 continuation byte mask (`0xC0`).
pub(crate) const WS_UTF8_CONT_MASK: u8 = 0xC0;

/// RFC 6455 UTF-8 continuation byte prefix (`0x80`).
pub(crate) const WS_UTF8_CONT_PREFIX: u8 = 0x80;

/// RFC 6455 extended 16-bit payload length marker (`126`).
pub(crate) const WS_LEN_EXT16: u8 = 126;

/// RFC 6455 extended 64-bit payload length marker (`127`).
pub(crate) const WS_LEN_EXT64: u8 = 127;

/// Maximum single-byte RFC 6455 payload length threshold (`126`).
pub(crate) const WS_LEN_SHORT_LIMIT: usize = 126;

/// RFC 6455 non-final frame flag (`0x00`).
pub(crate) const WS_NON_FIN_BIT: u8 = 0x00;

/// Field label rendered by `Debug` for [`WebSocket::broadcast_map`].
pub(crate) const WS_DEBUG_STRUCT_NAME: &str = "WebSocket";

/// Field name rendered by `Debug` for [`WebSocket::broadcast_map`].
pub(crate) const WS_DEBUG_BROADCAST_FIELD: &str = "broadcast_map";

/// Field name rendered by `Debug` for active sparse WebSocket rooms.
pub(crate) const WS_DEBUG_SPARSE_ROOMS_FIELD: &str = "sparse_rooms";