pub struct WebSocket<T> { /* private fields */ }Expand description
WebSocket struct
Trait Implementations§
Source§impl AsyncRead for WebSocket<UpgradedIo>
Available on crate feature tokio-rt only.
impl AsyncRead for WebSocket<UpgradedIo>
tokio-rt only.Source§impl AsyncWrite for WebSocket<UpgradedIo>
Available on crate feature tokio-rt only.
impl AsyncWrite for WebSocket<UpgradedIo>
tokio-rt only.Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf into the object. Read moreSource§fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read moreSource§impl DeboaWebSocket for WebSocket<UpgradedIo>
impl DeboaWebSocket for WebSocket<UpgradedIo>
Source§async fn read_message(&mut self) -> Result<Option<Message>, DeboaExtrasError>
async fn read_message(&mut self) -> Result<Option<Message>, DeboaExtrasError>
Source§async fn write_message(
&mut self,
message: Message,
) -> Result<(), DeboaExtrasError>
async fn write_message( &mut self, message: Message, ) -> Result<(), DeboaExtrasError>
Writes a message to the WebSocket.
§Arguments
message- The message to write.
§Returns
A Result indicating success or a DeboaExtrasError.
§Examples
let result = websocket
.write_message(protocol::Message::Text(message.to_string()))
.await;
if result.is_err() {
output.send(Event::Disconnected).await;
break;
}§Panics
This function may panic if the WebSocket frame processing fails.
Source§async fn send_close(
&mut self,
code: u16,
reason: &str,
) -> Result<(), DeboaExtrasError>
async fn send_close( &mut self, code: u16, reason: &str, ) -> Result<(), DeboaExtrasError>
Sends a close frame to the WebSocket.
§Arguments
code- The close code.reason- The close reason.
§Returns
A Result indicating success or a DeboaExtrasError.
§Examples
let result = websocket.send_close(1000, "Goodbye").await;
if result.is_err() {
output.send(Event::Disconnected).await;
break;
}§Panics
This function may panic if the WebSocket frame processing fails.
Source§async fn send_text(&mut self, message: &str) -> Result<(), DeboaExtrasError>
async fn send_text(&mut self, message: &str) -> Result<(), DeboaExtrasError>
Sends a text frame to the WebSocket.
§Arguments
message- The text message to send.
§Returns
A Result indicating success or a DeboaExtrasError.
§Examples
let result = websocket.send_text("Hello").await;
if result.is_err() {
output.send(Event::Disconnected).await;
break;
}§Panics
This function may panic if the WebSocket frame processing fails.
Source§async fn send_binary(&mut self, message: &[u8]) -> Result<(), DeboaExtrasError>
async fn send_binary(&mut self, message: &[u8]) -> Result<(), DeboaExtrasError>
Sends a binary frame to the WebSocket.
§Arguments
message- The binary message to send.
§Returns
A Result indicating success or a DeboaExtrasError.
§Examples
let result = websocket.send_binary(&[0x00, 0x01, 0x02]).await;
if result.is_err() {
output.send(Event::Disconnected).await;
break;
}§Panics
This function may panic if the WebSocket frame processing fails.
Source§async fn send_ping(&mut self, message: &[u8]) -> Result<(), DeboaExtrasError>
async fn send_ping(&mut self, message: &[u8]) -> Result<(), DeboaExtrasError>
Sends a ping frame to the WebSocket.
§Arguments
message- The ping message to send.
§Returns
A Result indicating success or a DeboaExtrasError.
§Examples
let result = websocket.send_ping(&[0x00, 0x01, 0x02]).await;
if result.is_err() {
output.send(Event::Disconnected).await;
break;
}§Panics
This function may panic if the WebSocket frame processing fails.
Source§async fn send_pong(&mut self, message: &[u8]) -> Result<(), DeboaExtrasError>
async fn send_pong(&mut self, message: &[u8]) -> Result<(), DeboaExtrasError>
Sends a pong frame to the WebSocket.
§Arguments
message- The pong message to send.
§Returns
A Result indicating success or a DeboaExtrasError.
§Examples
let result = websocket.send_pong(&[0x00, 0x01, 0x02]).await;
if result.is_err() {
output.send(Event::Disconnected).await;
break;
}§Panics
This function may panic if the WebSocket frame processing fails.
type Stream = TokioIo<Upgraded>
impl<'__pin, T> Unpin for WebSocket<T>where
PinnedFieldsOf<__Origin<'__pin, T>>: Unpin,
Auto Trait Implementations§
impl<T> Freeze for WebSocket<T>where
T: Freeze,
impl<T> RefUnwindSafe for WebSocket<T>where
T: RefUnwindSafe,
impl<T> Send for WebSocket<T>where
T: Send,
impl<T> Sync for WebSocket<T>where
T: Sync,
impl<T> UnsafeUnpin for WebSocket<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for WebSocket<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
Source§fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf. Read moreSource§fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
Source§fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
Source§fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
Source§fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
Source§fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
Source§fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
Source§fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
Source§fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
Source§fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
Source§fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
Source§fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
Source§fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
Source§fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
Source§fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
Source§fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
Source§fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
Source§fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
Source§fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
Source§fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
Source§fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
Source§fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
Source§fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
Source§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
buf. Read more