pub struct Packet {
pub packet_type: PacketId,
pub nsp: String,
pub data: Option<String>,
pub id: Option<u64>,
pub attachment_count: u8,
pub attachments: Option<Vec<Bytes>>,
}Expand description
A packet which gets sent or received during in the socket.io protocol.
Fields§
§packet_type: PacketId§nsp: String§data: Option<String>The JSON payload as text, placeholders included.
id: Option<u64>§attachment_count: u8§attachments: Option<Vec<Bytes>>Implementations§
Source§impl Packet
impl Packet
Sourcepub fn new_event(
payload: Payload,
event: &str,
nsp: &str,
id: Option<u64>,
) -> Result<Packet>
pub fn new_event( payload: Payload, event: &str, nsp: &str, id: Option<u64>, ) -> Result<Packet>
An EVENT (or BINARY_EVENT when the payload carries buffers) for event.
Sourcepub fn new_ack(payload: Payload, nsp: &str, id: u64) -> Result<Packet>
pub fn new_ack(payload: Payload, nsp: &str, id: u64) -> Result<Packet>
The ACK (or BINARY_ACK) that answers the server’s event id.
Sourcepub fn event_payload(&self) -> Result<(String, Payload)>
pub fn event_payload(&self) -> Result<(String, Payload)>
Event name and arguments of an EVENT / BINARY_EVENT.
The first argument is the name when it is a string (or a number, which socket.io-parser
also accepts). Deliberate difference from socket.io-client, kept from rust_socketio: a
binary event without a name (emit(buffer) on the server) is named "message".
Sourcepub fn ack_payload(&self) -> Result<Payload>
pub fn ack_payload(&self) -> Result<Payload>
The arguments of an ACK / BINARY_ACK.
Trait Implementations§
impl Eq for Packet
impl StructuralPartialEq for Packet
Auto Trait Implementations§
impl Forget for Packet
impl Freeze for Packet
impl Move for Packet
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnsafeUnpin for Packet
impl UnwindSafe for Packet
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