pub struct Connection<R>{ /* private fields */ }Expand description
一个Websocket连接
- 🎯处理单个Websocket连接
Trait Implementations§
Source§impl<R> Debug for Connection<R>
impl<R> Debug for Connection<R>
Source§impl<R> Handler for Connection<R>
impl<R> Handler for Connection<R>
Source§fn on_shutdown(&mut self)
fn on_shutdown(&mut self)
Called when a request to shutdown all connections has been received.
Source§fn on_open(&mut self, shake: Handshake) -> Result<()>
fn on_open(&mut self, shake: Handshake) -> Result<()>
Called when the WebSocket handshake is successful and the connection is open for sending
and receiving messages.
Source§fn on_close(&mut self, code: CloseCode, reason: &str)
fn on_close(&mut self, code: CloseCode, reason: &str)
Called any time this endpoint receives a close control frame.
This may be because the other endpoint is initiating a closing handshake,
or it may be the other endpoint confirming the handshake initiated by this endpoint.
Source§fn on_timeout(&mut self, event: Token) -> Result<()>
fn on_timeout(&mut self, event: Token) -> Result<()>
Called when a timeout is triggered. Read more
Source§fn on_new_timeout(&mut self, _: Token, _: Timeout) -> Result<()>
fn on_new_timeout(&mut self, _: Token, _: Timeout) -> Result<()>
Called when a timeout has been scheduled on the eventloop. Read more
Source§fn on_request(&mut self, req: &Request) -> Result<Response, Error>
fn on_request(&mut self, req: &Request) -> Result<Response, Error>
A method for handling the low-level workings of the request portion of the WebSocket
handshake. Read more
Source§fn on_response(&mut self, res: &Response) -> Result<(), Error>
fn on_response(&mut self, res: &Response) -> Result<(), Error>
A method for handling the low-level workings of the response portion of the WebSocket
handshake. Read more
Source§fn on_frame(&mut self, frame: Frame) -> Result<Option<Frame>, Error>
fn on_frame(&mut self, frame: Frame) -> Result<Option<Frame>, Error>
A method for handling incoming frames. Read more
Auto Trait Implementations§
impl<R> Freeze for Connection<R>
impl<R> RefUnwindSafe for Connection<R>
impl<R> Send for Connection<R>
impl<R> Sync for Connection<R>
impl<R> Unpin for Connection<R>
impl<R> UnwindSafe for Connection<R>
Blanket Implementations§
Source§impl<T> BoostWithOption for T
impl<T> BoostWithOption for T
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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 moreSource§impl<T> JoinTo for T
impl<T> JoinTo for T
Source§fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more
Source§impl<T> JoinTo for T
impl<T> JoinTo for T
Source§fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more