Enum trillium_websockets::Message
source · pub enum Message {
Text(String),
Binary(Vec<u8>),
Ping(Vec<u8>),
Pong(Vec<u8>),
Close(Option<CloseFrame<'static>>),
Frame(Frame),
}
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
Ping(Vec<u8>)
A ping message with the specified payload
The payload here must have a length less than 125 bytes
Pong(Vec<u8>)
A pong message with the specified payload
The payload here must have a length less than 125 bytes
Close(Option<CloseFrame<'static>>)
A close message with the optional close frame.
Frame(Frame)
Raw frame. Note, that you’re not going to get this value while reading the message.
Implementations§
source§impl Message
impl Message
sourcepub fn binary<B>(bin: B) -> Message
pub fn binary<B>(bin: B) -> Message
Create a new binary WebSocket message by converting to Vec<u8>
.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the WebSocket message has no content. For example, if the other side of the connection sent an empty string.
Trait Implementations§
source§impl PartialEq for Message
impl PartialEq for Message
source§impl<T> Sink<Message> for WebSocketStream<T>
impl<T> Sink<Message> for WebSocketStream<T>
source§fn poll_ready(
self: Pin<&mut WebSocketStream<T>>,
cx: &mut Context<'_>
) -> Poll<Result<(), <WebSocketStream<T> as Sink<Message>>::Error>>
fn poll_ready( self: Pin<&mut WebSocketStream<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), <WebSocketStream<T> as Sink<Message>>::Error>>
Attempts to prepare the
Sink
to receive a value. Read moresource§fn start_send(
self: Pin<&mut WebSocketStream<T>>,
item: Message
) -> Result<(), <WebSocketStream<T> as Sink<Message>>::Error>
fn start_send( self: Pin<&mut WebSocketStream<T>>, item: Message ) -> Result<(), <WebSocketStream<T> as Sink<Message>>::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read moresource§fn poll_flush(
self: Pin<&mut WebSocketStream<T>>,
cx: &mut Context<'_>
) -> Poll<Result<(), <WebSocketStream<T> as Sink<Message>>::Error>>
fn poll_flush( self: Pin<&mut WebSocketStream<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), <WebSocketStream<T> as Sink<Message>>::Error>>
Flush any remaining output from this sink. Read more
source§fn poll_close(
self: Pin<&mut WebSocketStream<T>>,
cx: &mut Context<'_>
) -> Poll<Result<(), <WebSocketStream<T> as Sink<Message>>::Error>>
fn poll_close( self: Pin<&mut WebSocketStream<T>>, cx: &mut Context<'_> ) -> Poll<Result<(), <WebSocketStream<T> as Sink<Message>>::Error>>
Flush any remaining output and close this sink, if necessary. Read more
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