pub enum Payload {
Binary(Bytes, Option<i32>),
Text(Vec<Value>, Option<i32>),
String(String, Option<i32>),
}Expand description
A type which represents a payload in the socket.io context.
A payload could either be of the type Payload::Binary, which holds
data in the Bytes type that represents the payload or of the type
Payload::String which holds a std::string::String. The enum is
used for both representing data that’s send and data that’s received.
The optional i32 field represents the ack ID if this payload
requires acknowledgment from the server.
Variants§
Binary(Bytes, Option<i32>)
Text(Vec<Value>, Option<i32>)
String(String, Option<i32>)
👎Deprecated:
Use Payload::Text instead. Continue existing behavior with: Payload::from(String)
String that is sent as JSON if this is a JSON string, or as a raw string if it isn’t
Implementations§
Source§impl Payload
impl Payload
Sourcepub fn with_ack_id<T: Into<Self>>(payload: T, ack_id: i32) -> Self
pub fn with_ack_id<T: Into<Self>>(payload: T, ack_id: i32) -> Self
创建一个带ack_id的payload
Sourcepub fn set_ack_id(&mut self, ack_id: Option<i32>)
pub fn set_ack_id(&mut self, ack_id: Option<i32>)
设置payload的ack_id
Sourcepub fn data(&self) -> PayloadData<'_>
pub fn data(&self) -> PayloadData<'_>
获取payload的数据部分(不包含ack_id)
Trait Implementations§
impl Eq for Payload
impl StructuralPartialEq for Payload
Auto Trait Implementations§
impl !Freeze for Payload
impl RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl UnsafeUnpin for Payload
impl UnwindSafe for Payload
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.