hyperlane-plugin-websocket 22.14.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::*;

/// A trait for types that can be used as broadcast identifiers.
///
/// Types implementing this trait must be convertible to a string,
/// be partially orderable, and be cloneable.
pub trait BroadcastTypeTrait: ToString + PartialOrd + Clone {
    /// Returns a direct borrowed string view when this identifier is already UTF-8 text.
    ///
    /// # Returns
    ///
    /// - `Option<&str>` - Direct borrowed slice, or `None` for non-string identifier types.
    #[doc(hidden)]
    #[inline(always)]
    fn as_broadcast_str(&self) -> Option<&str> {
        None
    }

    /// Writes this identifier directly into `f` without intermediate `String` allocation.
    ///
    /// # Arguments
    ///
    /// - `&mut dyn Write` - Destination formatting writer.
    ///
    /// # Returns
    ///
    /// - `fmt::Result` - Formatting outcome.
    #[doc(hidden)]
    fn write_broadcast_key(&self, f: &mut dyn Write) -> fmt::Result {
        f.write_str(&self.to_string())
    }
}