pub struct WebSocket { /* private fields */ }Available on crate feature
websocket only.Expand description
Then WebSocket provides the API for creating and managing a WebSocket connection, as well as for sending and receiving data on the connection.
Implementations§
source§impl WebSocket
impl WebSocket
sourcepub fn protocols<I>(self, protocols: I) -> Selfwhere
I: IntoIterator,
I::Item: Into<Cow<'static, str>>,
pub fn protocols<I>(self, protocols: I) -> Selfwhere I: IntoIterator, I::Item: Into<Cow<'static, str>>,
The specifies one or more protocols that you wish to use.
In order of preference. The first one that is supported by the server will be selected and responsed.
sourcepub fn on_upgrade_with_config<F, Fut>(
self,
callback: F,
config: Option<WebSocketConfig>
) -> Responsewhere
F: FnOnce(WebSocketStream) -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
pub fn on_upgrade_with_config<F, Fut>( self, callback: F, config: Option<WebSocketConfig> ) -> Responsewhere F: FnOnce(WebSocketStream) -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static,
Finish the upgrade, passing a function and a WebSocketConfig to handle the WebSocket.
sourcepub fn on_upgrade<F, Fut>(self, callback: F) -> Responsewhere
F: FnOnce(WebSocketStream) -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
pub fn on_upgrade<F, Fut>(self, callback: F) -> Responsewhere F: FnOnce(WebSocketStream) -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static,
Finish the upgrade, passing a function to handle the WebSocket.
Trait Implementations§
source§impl FromRequest for WebSocket
impl FromRequest for WebSocket
§type Error = WebSocketError
type Error = WebSocketError
The type returned in the event of a conversion error.
source§impl IntoResponse for WebSocket
impl IntoResponse for WebSocket
source§fn into_response(self) -> Response
fn into_response(self) -> Response
Convert self to HTTP
Response.source§fn into_error(self) -> Error
fn into_error(self) -> Error
Convert self to the
Error.