pub struct WebSocketStream<S> { /* private fields */ }Available on crate feature
ws only.Expand description
A WebSocket stream that works with compio.
Implementations§
Source§impl<S> WebSocketStream<S>
impl<S> WebSocketStream<S>
Source§impl<S> WebSocketStream<S>where
S: AsyncRead + AsyncWrite,
impl<S> WebSocketStream<S>where
S: AsyncRead + AsyncWrite,
Sourcepub async fn from_raw_socket(
stream: S,
role: Role,
config: impl Into<Config>,
) -> WebSocketStream<S>
pub async fn from_raw_socket( stream: S, role: Role, config: impl Into<Config>, ) -> WebSocketStream<S>
Convert a raw socket into a WebSocketStream without performing a
handshake.
disable_nagle will be ignored since the socket is already connected
and the user can set nodelay on the socket directly before calling
this function if needed.
Sourcepub async fn from_partially_read(
stream: S,
part: Vec<u8>,
role: Role,
config: impl Into<Config>,
) -> WebSocketStream<S>
pub async fn from_partially_read( stream: S, part: Vec<u8>, role: Role, config: impl Into<Config>, ) -> WebSocketStream<S>
Convert a raw socket into a WebSocketStream without performing a
handshake.
disable_nagle will be ignored since the socket is already connected
and the user can set nodelay on the socket directly before calling
this function if needed.
Sourcepub async fn send(&mut self, message: Message) -> Result<(), Error>
pub async fn send(&mut self, message: Message) -> Result<(), Error>
Send a message on the WebSocket stream.
Sourcepub async fn read(&mut self) -> Result<Message, Error>
pub async fn read(&mut self) -> Result<Message, Error>
Read a message from the WebSocket stream.
Sourcepub async fn close(
&mut self,
close_frame: Option<CloseFrame>,
) -> Result<(), Error>
pub async fn close( &mut self, close_frame: Option<CloseFrame>, ) -> Result<(), Error>
Close the WebSocket connection.
Sourcepub fn into_compat(self) -> CompatWebSocketStream<S>
Available on crate feature io-compat only.
pub fn into_compat(self) -> CompatWebSocketStream<S>
io-compat only.Convert this stream into a [futures_util] compatible stream.
Trait Implementations§
Source§impl<S> Debug for WebSocketStream<S>where
S: Debug,
impl<S> Debug for WebSocketStream<S>where
S: Debug,
Source§impl<S> IntoInner for WebSocketStream<S>
impl<S> IntoInner for WebSocketStream<S>
Source§type Inner = WebSocket<SyncStream<S>>
type Inner = WebSocket<SyncStream<S>>
The inner type.
Source§fn into_inner(self) -> <WebSocketStream<S> as IntoInner>::Inner
fn into_inner(self) -> <WebSocketStream<S> as IntoInner>::Inner
Get the inner buffer.
Auto Trait Implementations§
impl<S> !Freeze for WebSocketStream<S>
impl<S> RefUnwindSafe for WebSocketStream<S>where
S: RefUnwindSafe,
impl<S> Send for WebSocketStream<S>where
S: Send,
impl<S> Sync for WebSocketStream<S>where
S: Sync,
impl<S> Unpin for WebSocketStream<S>where
S: Unpin,
impl<S> UnsafeUnpin for WebSocketStream<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for WebSocketStream<S>where
S: UnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more