pub struct WebSocketConnection { /* private fields */ }Expand description
An upgraded connection. recv returns the client’s
messages, answering pings and the closing handshake itself; send with
the methods here or a WebSocketSender from sender,
which another thread can use while this one waits in recv.
Implementations§
Source§impl WebSocketConnection
impl WebSocketConnection
Sourcepub fn max_message_size(self, bytes: usize) -> WebSocketConnection
pub fn max_message_size(self, bytes: usize) -> WebSocketConnection
Refuse messages over bytes (default MAX_MESSAGE) with close
code 1009.
Sourcepub fn sender(&self) -> WebSocketSender
pub fn sender(&self) -> WebSocketSender
A sender for this connection, for other threads.
Sourcepub fn close(&self, code: u16, reason: &str) -> Result<(), String>
pub fn close(&self, code: u16, reason: &str) -> Result<(), String>
Start the closing handshake; recv then returns
Ok(None) when the client answers.
Sourcepub fn recv(&mut self) -> Result<Option<Message>, String>
pub fn recv(&mut self) -> Result<Option<Message>, String>
The next message; Ok(None) once the connection closed cleanly
(the closing handshake done, whoever started it). Pings are
answered and pongs dropped on the way. A protocol error — an
unmasked frame, a bad fragment, invalid UTF-8, an oversized message
— closes the connection with the matching code and is returned as
Err, as is the client disappearing without a close frame.
Auto Trait Implementations§
impl !RefUnwindSafe for WebSocketConnection
impl !Sync for WebSocketConnection
impl !UnwindSafe for WebSocketConnection
impl Freeze for WebSocketConnection
impl Send for WebSocketConnection
impl Unpin for WebSocketConnection
impl UnsafeUnpin for WebSocketConnection
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.