pub enum Frame {
Subscribe {
id: u64,
channel: String,
},
Unsubscribe {
id: u64,
channel: String,
},
Publish {
id: Option<u64>,
channel: String,
event: Option<String>,
payload: Vec<u8>,
},
Presence {
id: u64,
channel: String,
action: PresenceAction,
data: Option<Value>,
},
Ack {
id: u64,
},
Error {
id: u64,
code: u16,
message: String,
},
Ping {
timestamp: Option<u64>,
},
Pong {
timestamp: Option<u64>,
},
Connect {
version: u8,
token: Option<String>,
},
Connected {
connection_id: String,
version: u8,
heartbeat: u32,
},
}Expand description
A protocol frame.
Frames are the messages exchanged between clients and servers. Each frame type has specific fields relevant to its operation.
Variants§
Subscribe
Subscribe to a channel.
Unsubscribe
Unsubscribe from a channel.
Publish
Publish a message to a channel.
Fields
Presence
Presence update.
Fields
§
action: PresenceActionPresence action.
Ack
Acknowledgment of a request.
Error
Error response.
Fields
Ping
Keepalive ping.
Pong
Keepalive pong.
Connect
Initial connection handshake.
Connected
Connection established response.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn frame_type(&self) -> FrameType
pub fn frame_type(&self) -> FrameType
Get the frame type.
Sourcepub fn unsubscribe(id: u64, channel: impl Into<String>) -> Self
pub fn unsubscribe(id: u64, channel: impl Into<String>) -> Self
Create a new Unsubscribe frame.
Sourcepub fn publish(channel: impl Into<String>, payload: impl Into<Vec<u8>>) -> Self
pub fn publish(channel: impl Into<String>, payload: impl Into<Vec<u8>>) -> Self
Create a new Publish frame.
Sourcepub fn publish_with_ack(
id: u64,
channel: impl Into<String>,
payload: impl Into<Vec<u8>>,
) -> Self
pub fn publish_with_ack( id: u64, channel: impl Into<String>, payload: impl Into<Vec<u8>>, ) -> Self
Create a new Publish frame with ID for acknowledgment.
Sourcepub fn ping_with_timestamp(timestamp: u64) -> Self
pub fn ping_with_timestamp(timestamp: u64) -> Self
Create a new Ping frame with timestamp.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Frame
impl<'de> Deserialize<'de> for Frame
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more