[−][src]Struct websocket_lite::Message
A text string or a block of binary data that can be sent or recevied over a WebSocket.
Methods
impl Message[src]
impl Messagepub fn new<B: Into<Bytes>>(opcode: Opcode, data: B) -> Result<Self, Utf8Error>[src]
pub fn new<B: Into<Bytes>>(opcode: Opcode, data: B) -> Result<Self, Utf8Error>Creates a message from a Bytes object.
The message can be tagged as text or binary. When the is_text is true this function validates the bytes in
data and returns Err if they do not contain valid UTF-8 text.
pub fn text(data: &str) -> Self[src]
pub fn text(data: &str) -> SelfCreates a text message from a &str.
pub fn binary<B: Into<Bytes>>(data: B) -> Self[src]
pub fn binary<B: Into<Bytes>>(data: B) -> SelfCreates a binary message from any type that can be converted to Bytes, such as &[u8] or Vec<u8>.
pub fn close(reason: Option<(u16, &str)>) -> Self[src]
pub fn close(reason: Option<(u16, &str)>) -> SelfCreates a message that indicates the connection is about to be closed.
pub fn ping<B: Into<Bytes>>(data: B) -> Self[src]
pub fn ping<B: Into<Bytes>>(data: B) -> SelfCreates a message requesting a pong response.
pub fn pong<B: Into<Bytes>>(data: B) -> Self[src]
pub fn pong<B: Into<Bytes>>(data: B) -> SelfCreates a response to a ping message.
pub fn opcode(&self) -> Opcode[src]
pub fn opcode(&self) -> OpcodeReturns this message's WebSocket opcode.
pub fn data(&self) -> &Bytes[src]
pub fn data(&self) -> &BytesReturns a reference to the data held in this message.
pub fn into_data(self) -> Bytes[src]
pub fn into_data(self) -> BytesConsumes the message, returning its data.
pub fn as_text(&self) -> Option<&str>[src]
pub fn as_text(&self) -> Option<&str>For text messages, return a reference to the text.
Trait Implementations
impl PartialEq<Message> for Message[src]
impl PartialEq<Message> for Messagefn eq(&self, other: &Message) -> bool[src]
fn eq(&self, other: &Message) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Message) -> bool[src]
fn ne(&self, other: &Message) -> boolThis method tests for !=.
impl Clone for Message[src]
impl Clone for Messagefn clone(&self) -> Message[src]
fn clone(&self) -> MessageReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Message[src]
impl Debug for MessageAuto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T[src]
impl<T> From for Timpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more
impl<T> Erased for T
impl<T> Erased for T