pub enum Message {
Text(String),
Binary(Vec<u8>),
Close(Option<(u16, String)>),
}Expand description
An enum representing the various forms of a WebSocket message.
Variants§
Text(String)
A text WebSocket message.
Binary(Vec<u8>)
A binary WebSocket message.
Close(Option<(u16, String)>)
Message sent when the connection is closed.
Implementations§
Source§impl Message
impl Message
Sourcepub fn as_text_mut(&mut self) -> Option<&mut String>
pub fn as_text_mut(&mut self) -> Option<&mut String>
Optionally returns mutable references to the inner fields if this is a Message::Text, otherwise None
Sourcepub fn as_text(&self) -> Option<&String>
pub fn as_text(&self) -> Option<&String>
Optionally returns references to the inner fields if this is a Message::Text, otherwise None
Sourcepub fn into_text(self) -> Result<String, Self>
pub fn into_text(self) -> Result<String, Self>
Returns the inner fields if this is a Message::Text, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_binary_mut(&mut self) -> Option<&mut Vec<u8>>
pub fn as_binary_mut(&mut self) -> Option<&mut Vec<u8>>
Optionally returns mutable references to the inner fields if this is a Message::Binary, otherwise None
Sourcepub fn as_binary(&self) -> Option<&Vec<u8>>
pub fn as_binary(&self) -> Option<&Vec<u8>>
Optionally returns references to the inner fields if this is a Message::Binary, otherwise None
Sourcepub fn into_binary(self) -> Result<Vec<u8>, Self>
pub fn into_binary(self) -> Result<Vec<u8>, Self>
Returns the inner fields if this is a Message::Binary, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_close_mut(&mut self) -> Option<&mut Option<(u16, String)>>
pub fn as_close_mut(&mut self) -> Option<&mut Option<(u16, String)>>
Optionally returns mutable references to the inner fields if this is a Message::Close, otherwise None
Trait Implementations§
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)