pub enum WebSocketMessage {
Text(String),
Binary(Vec<u8>),
Ping(Vec<u8>),
Pong(Vec<u8>),
Close(Option<CloseFrame>),
}
Expand description
WebSocket message types - clean API over tungstenite
Variants§
Text(String)
Text message
Binary(Vec<u8>)
Binary message
Ping(Vec<u8>)
Ping frame
Pong(Vec<u8>)
Pong frame
Close(Option<CloseFrame>)
Close frame
Implementations§
Source§impl WebSocketMessage
impl WebSocketMessage
pub fn text<T: Into<String>>(content: T) -> Self
pub fn binary<T: Into<Vec<u8>>>(data: T) -> Self
pub fn ping<T: Into<Vec<u8>>>(data: T) -> Self
pub fn pong<T: Into<Vec<u8>>>(data: T) -> Self
pub fn close() -> Self
pub fn close_with_reason(code: u16, reason: String) -> Self
pub fn message_type(&self) -> MessageType
pub fn is_text(&self) -> bool
pub fn is_binary(&self) -> bool
pub fn is_control(&self) -> bool
Trait Implementations§
Source§impl Clone for WebSocketMessage
impl Clone for WebSocketMessage
Source§fn clone(&self) -> WebSocketMessage
fn clone(&self) -> WebSocketMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for WebSocketMessage
impl Debug for WebSocketMessage
Source§impl<'de> Deserialize<'de> for WebSocketMessage
impl<'de> Deserialize<'de> for WebSocketMessage
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
Source§impl From<Message> for WebSocketMessage
impl From<Message> for WebSocketMessage
Source§impl From<WebSocketMessage> for Message
impl From<WebSocketMessage> for Message
Source§fn from(msg: WebSocketMessage) -> Self
fn from(msg: WebSocketMessage) -> Self
Converts to this type from the input type.
Source§impl PartialEq for WebSocketMessage
impl PartialEq for WebSocketMessage
Source§impl Serialize for WebSocketMessage
impl Serialize for WebSocketMessage
impl StructuralPartialEq for WebSocketMessage
Auto Trait Implementations§
impl Freeze for WebSocketMessage
impl RefUnwindSafe for WebSocketMessage
impl Send for WebSocketMessage
impl Sync for WebSocketMessage
impl Unpin for WebSocketMessage
impl UnwindSafe for WebSocketMessage
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