Connection

Struct Connection 

Source
pub struct Connection<R>
where R: VmRuntime + Send + Sync,
{ /* private fields */ }
Expand description

一个Websocket连接

  • 🎯处理单个Websocket连接

Trait Implementations§

Source§

impl<R> Debug for Connection<R>
where R: VmRuntime + Send + Sync + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R> Handler for Connection<R>
where R: VmRuntime + Send + Sync + 'static,

Source§

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<()>

Called when the WebSocket handshake is successful and the connection is open for sending and receiving messages.
Source§

fn on_message(&mut self, msg: Message) -> Result<()>

Called on incoming messages.
Source§

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_error(&mut self, err: Error)

Called when an error occurs on the WebSocket.
Source§

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<()>

Called when a timeout has been scheduled on the eventloop. Read more
Source§

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>

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>

A method for handling incoming frames. Read more
Source§

fn on_send_frame(&mut self, frame: Frame) -> Result<Option<Frame>, Error>

A method for handling outgoing frames. Read more
Source§

fn build_request(&mut self, url: &Url) -> Result<Request, Error>

A method for creating the initial handshake request for WebSocket clients. 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§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> BoostWithOption for T

Source§

fn option<C>(self, criterion: C) -> Option<Self>
where C: FnOnce(&Self) -> bool,

根据某条件把自身变为可选值 Read more
Source§

fn some(self) -> Option<Self>

将自身封装为Some Read more
Source§

fn none(self) -> Option<Self>

将自身封装为None Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> JoinTo for T

Source§

fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more
Source§

fn join_to_new<S>(self, sep: impl AsRef<str>) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中 Read more
Source§

fn join_to_multi<S>(self, out: &mut String, sep: &[impl AsRef<str>])
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,使用多个分隔符,中途不创建任何辅助字符串 Read more
Source§

fn join_to_multi_new<S>(self, sep: &[impl AsRef<str>]) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中,使用多个分隔符 Read more
Source§

impl<T> JoinTo for T

Source§

fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more
Source§

fn join_to_new<S>(self, sep: impl AsRef<str>) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中 Read more
Source§

fn join_to_multi<S>(self, out: &mut String, sep: &[impl AsRef<str>])
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,使用多个分隔符,中途不创建任何辅助字符串 Read more
Source§

fn join_to_multi_new<S>(self, sep: &[impl AsRef<str>]) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中,使用多个分隔符 Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToDebug for T
where T: Debug,

Source§

fn to_debug(&self) -> String

将对象转换为「用Debug格式化的字符串」

Source§

impl<T> ToDebug for T
where T: Debug,

Source§

fn to_debug(&self) -> String

将对象转换为「用Debug格式化的字符串」

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Void for T

Source§

fn void(self)

Source§

impl<T> Void for T

Source§

fn void(self)