[−][src]Struct tungstenite::protocol::WebSocket
WebSocket input-output stream.
This is THE structure you want to create to be able to speak the WebSocket protocol.
It may be created by calling connect
, accept
or client
functions.
Methods
impl<Stream> WebSocket<Stream>
[src]
pub fn from_raw_socket(
stream: Stream,
role: Role,
config: Option<WebSocketConfig>
) -> Self
[src]
stream: Stream,
role: Role,
config: Option<WebSocketConfig>
) -> Self
Convert a raw socket into a WebSocket without performing a handshake.
Call this function if you're using Tungstenite as a part of a web framework
or together with an existing one. If you need an initial handshake, use
connect()
or accept()
functions of the crate to construct a websocket.
pub fn from_partially_read(
stream: Stream,
part: Vec<u8>,
role: Role,
config: Option<WebSocketConfig>
) -> Self
[src]
stream: Stream,
part: Vec<u8>,
role: Role,
config: Option<WebSocketConfig>
) -> Self
Convert a raw socket into a WebSocket without performing a handshake.
Call this function if you're using Tungstenite as a part of a web framework
or together with an existing one. If you need an initial handshake, use
connect()
or accept()
functions of the crate to construct a websocket.
pub fn get_ref(&self) -> &Stream
[src]
Returns a shared reference to the inner stream.
pub fn get_mut(&mut self) -> &mut Stream
[src]
Returns a mutable reference to the inner stream.
pub fn set_config(
&mut self,
set_func: impl FnOnce(&mut WebSocketConfig)
)
[src]
&mut self,
set_func: impl FnOnce(&mut WebSocketConfig)
)
Change the configuration.
impl<Stream: Read + Write> WebSocket<Stream>
[src]
pub fn read_message(&mut self) -> Result<Message>
[src]
Read a message from stream, if possible.
This function sends pong and close responses automatically. However, it never blocks on write.
pub fn write_message(&mut self, message: Message) -> Result<()>
[src]
Send a message to 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 close(&mut self, code: Option<CloseFrame>) -> Result<()>
[src]
Close the connection.
This function guarantees that the close frame will be queued. There is no need to call it again.
pub fn write_pending(&mut self) -> Result<()>
[src]
Flush the pending send queue.
Trait Implementations
Auto Trait Implementations
impl<Stream> Send for WebSocket<Stream> where
Stream: Send,
Stream: Send,
impl<Stream> Sync for WebSocket<Stream> where
Stream: Sync,
Stream: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
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]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
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]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
impl<T> Same for T
type Output = T
Should always be Self