#[repr(u8)]pub enum ProtocolVersion {
V1 = 1,
V2 = 2,
}Expand description
Protocol version negotiated per-connection.
- V1 (default): Pusher-compatible. Uses
pusher:/pusher_internal:prefixes. Features like serial, message_id, and recovery are opt-in via server config. - V2: Sockudo-native. Uses
sockudo:/sockudo_internal:prefixes. Serial, message_id, and connection recovery are always enabled.
Variants§
Implementations§
Source§impl ProtocolVersion
impl ProtocolVersion
Sourcepub fn from_query_param(value: Option<u8>) -> Self
pub fn from_query_param(value: Option<u8>) -> Self
Parse from the ?protocol= query parameter value.
Returns V1 for unrecognized values.
Sourcepub const fn event_prefix(&self) -> &'static str
pub const fn event_prefix(&self) -> &'static str
Event prefix for this protocol version (e.g. "pusher:" or "sockudo:").
Sourcepub const fn internal_prefix(&self) -> &'static str
pub const fn internal_prefix(&self) -> &'static str
Internal event prefix (e.g. "pusher_internal:" or "sockudo_internal:").
Sourcepub const fn is_serial_native(&self) -> bool
pub const fn is_serial_native(&self) -> bool
Whether serial numbers are native (always-on) for this protocol version.
Sourcepub const fn is_message_id_native(&self) -> bool
pub const fn is_message_id_native(&self) -> bool
Whether message_id is native (always-on) for this protocol version.
Sourcepub const fn is_recovery_native(&self) -> bool
pub const fn is_recovery_native(&self) -> bool
Whether connection recovery is native (always-on) for this protocol version.
Sourcepub fn wire_event(&self, canonical: &str) -> String
pub fn wire_event(&self, canonical: &str) -> String
Build a wire-format event name from a canonical name.
E.g. "subscribe" → "pusher:subscribe" or "sockudo:subscribe".
Sourcepub fn wire_internal_event(&self, canonical: &str) -> String
pub fn wire_internal_event(&self, canonical: &str) -> String
Build a wire-format internal event name from a canonical name.
E.g. "subscription_succeeded" → "pusher_internal:subscription_succeeded".
Sourcepub fn parse_event_name<'a>(&self, wire: &'a str) -> Option<&'a str>
pub fn parse_event_name<'a>(&self, wire: &'a str) -> Option<&'a str>
Strip the protocol prefix from a wire-format event name, returning the canonical name.
Returns None if the event doesn’t match this version’s prefix.
Sourcepub fn parse_any_protocol_event(wire: &str) -> Option<(&str, bool)>
pub fn parse_any_protocol_event(wire: &str) -> Option<(&str, bool)>
Determine if a wire event name belongs to ANY known protocol version, returning the canonical name and whether it’s internal.
Sourcepub fn rewrite_event_prefix(&self, event: &str) -> String
pub fn rewrite_event_prefix(&self, event: &str) -> String
Rewrite a pusher: or pusher_internal: event name to this version’s prefix.
If the event doesn’t have a known prefix, returns it unchanged.
Trait Implementations§
Source§impl Clone for ProtocolVersion
impl Clone for ProtocolVersion
Source§fn clone(&self) -> ProtocolVersion
fn clone(&self) -> ProtocolVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more