[−][src]Struct tungstenite::protocol::WebSocketContext
A context for managing WebSocket stream.
Methods
impl WebSocketContext
[src]
pub fn new(role: Role, config: Option<WebSocketConfig>) -> Self
[src]
Create a WebSocket context that manages a post-handshake stream.
pub fn from_partially_read(
part: Vec<u8>,
role: Role,
config: Option<WebSocketConfig>
) -> Self
[src]
part: Vec<u8>,
role: Role,
config: Option<WebSocketConfig>
) -> Self
Create a WebSocket context that manages an post-handshake stream.
pub fn set_config(&mut self, set_func: impl FnOnce(&mut WebSocketConfig))
[src]
Change the configuration.
pub fn read_message<Stream>(&mut self, stream: &mut Stream) -> Result<Message> where
Stream: Read + Write,
[src]
Stream: Read + Write,
Read a message from the provided stream, if possible.
This function sends pong and close responses automatically. However, it never blocks on write.
pub fn write_message<Stream>(
&mut self,
stream: &mut Stream,
message: Message
) -> Result<()> where
Stream: Read + Write,
[src]
&mut self,
stream: &mut Stream,
message: Message
) -> Result<()> where
Stream: Read + Write,
Send a message to the provided stream, if possible.
WebSocket will buffer a configurable number of messages at a time, except to reply to Ping
and Close requests. If the WebSocket's send queue is full, SendQueueFull
will be returned
along with the passed message. Otherwise, the message is queued and Ok(()) is returned.
Note that only the last pong frame is stored to be sent, and only the most recent pong frame is sent if multiple pong frames are queued.
pub fn write_pending<Stream>(&mut self, stream: &mut Stream) -> Result<()> where
Stream: Read + Write,
[src]
Stream: Read + Write,
Flush the pending send queue.
pub fn close<Stream>(
&mut self,
stream: &mut Stream,
code: Option<CloseFrame>
) -> Result<()> where
Stream: Read + Write,
[src]
&mut self,
stream: &mut Stream,
code: Option<CloseFrame>
) -> Result<()> where
Stream: Read + Write,
Close the connection.
This function guarantees that the close frame will be queued.
There is no need to call it again. Calling this function is
the same as calling write(Message::Close(..))
.
Trait Implementations
Auto Trait Implementations
impl Sync for WebSocketContext
impl Unpin for WebSocketContext
impl Send for WebSocketContext
impl UnwindSafe for WebSocketContext
impl RefUnwindSafe for WebSocketContext
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self