pub struct Message { /* private fields */ }Expand description
A WebSocket message.
This will likely become a non-exhaustive enum in the future, once that
language feature has stabilized.
Implementations§
Source§impl Message
impl Message
Sourcepub fn pong<V>(v: V) -> Message
pub fn pong<V>(v: V) -> Message
Construct a new Pong Message.
Note that one rarely needs to manually construct a Pong message because the underlying tungstenite socket automatically responds to the Ping messages it receives. Manual construction might still be useful in some cases like in tests or to send unidirectional heartbeats.
Sourcepub fn close_with(
code: impl Into<u16>,
reason: impl Into<Cow<'static, str>>,
) -> Message
pub fn close_with( code: impl Into<u16>, reason: impl Into<Cow<'static, str>>, ) -> Message
Construct a Close Message with a code and reason.
Sourcepub fn close_frame(&self) -> Option<(u16, &str)>
pub fn close_frame(&self) -> Option<(u16, &str)>
Try to get the close frame (close code and reason)
Sourcepub fn to_str(&self) -> Result<&str, ()>
pub fn to_str(&self) -> Result<&str, ()>
Try to get a reference to the string text, if this is a Text message.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Return the bytes of this message, if the message can contain data.
Sourcepub fn into_bytes(self) -> Vec<u8>
pub fn into_bytes(self) -> Vec<u8>
Destructure this message into binary data.
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§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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.