Enum Message
enum Message
An enum representing the various forms of a WebSocket message.
Variants
-
Text(crate::protocol::frame::Utf8Bytes) A text WebSocket message
-
Binary(bytes::Bytes) A binary WebSocket message
-
Ping(bytes::Bytes) A ping message with the specified payload
The payload here must have a length less than 125 bytes
-
Pong(bytes::Bytes) A pong message with the specified payload
The payload here must have a length less than 125 bytes
-
Close(Option<super::frame::CloseFrame>) A close message with the optional close frame.
-
Frame(super::frame::Frame) Raw frame. Note, that you're not going to get this value while reading the message.
Implementations
impl Message
fn text<S>(string: S) -> Message where S: Into<Utf8Bytes>Create a new text WebSocket message from a stringable.
fn binary<B>(bin: B) -> Message where B: Into<Bytes>Create a new binary WebSocket message by converting to
Bytes.fn is_text(self: &Self) -> boolIndicates whether a message is a text message.
fn is_binary(self: &Self) -> boolIndicates whether a message is a binary message.
fn is_ping(self: &Self) -> boolIndicates whether a message is a ping message.
fn is_pong(self: &Self) -> boolIndicates whether a message is a pong message.
fn is_close(self: &Self) -> boolIndicates whether a message is a close message.
fn len(self: &Self) -> usizeGet the length of the WebSocket message.
fn is_empty(self: &Self) -> boolReturns true if the WebSocket message has no content. For example, if the other side of the connection sent an empty string.
fn into_data(self: Self) -> BytesConsume the WebSocket and return it as binary data.
fn into_text(self: Self) -> Result<Utf8Bytes>Attempt to consume the WebSocket message and convert it to a String.
fn to_text(self: &Self) -> Result<&str>Attempt to get a &str from the WebSocket message, this will try to convert binary data to utf8.
impl Clone for Message
fn clone(self: &Self) -> Message
impl Debug for Message
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Display for Message
fn fmt(self: &Self, f: &mut Formatter<'_>) -> StdResult<(), Error>
impl Eq for Message
impl Freeze for Message
impl From for Message
fn from(string: String) -> Self
impl From for Message
fn from(data: Vec<u8>) -> Self
impl PartialEq for Message
fn eq(self: &Self, other: &Message) -> bool
impl RefUnwindSafe for Message
impl Send for Message
impl StructuralPartialEq for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
impl<'b> From for Message
fn from(data: &'b [u8]) -> Self
impl<'s> From for Message
fn from(string: &'s str) -> Self
impl<T> Any for Message
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Message
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Message
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Message
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Message
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Same for Message
impl<T> ToOwned for Message
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> ToString for Message
fn to_string(self: &Self) -> String
impl<T, U> Into for Message
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Message
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Message
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<V, T> VZip for Message
fn vzip(self: Self) -> V