pub struct WebSocketUpgrade { /* private fields */ }Expand description
Extractor that validates an HTTP/1.1 WebSocket handshake and upgrades the connection.
Implementations§
Source§impl WebSocketUpgrade
impl WebSocketUpgrade
Sourcepub fn allowed_origin(self, origin: impl Into<String>) -> WebSocketUpgrade
pub fn allowed_origin(self, origin: impl Into<String>) -> WebSocketUpgrade
Allow an exact Origin value. Repeating builds an allowlist.
Sourcepub fn any_origin(self) -> WebSocketUpgrade
pub fn any_origin(self) -> WebSocketUpgrade
Disable Origin checks. Intended for local tests, not production browsers.
Sourcepub fn max_message_size(
self,
bytes: usize,
) -> Result<WebSocketUpgrade, WebSocketConfigError>
pub fn max_message_size( self, bytes: usize, ) -> Result<WebSocketUpgrade, WebSocketConfigError>
Sourcepub fn max_frame_size(
self,
bytes: usize,
) -> Result<WebSocketUpgrade, WebSocketConfigError>
pub fn max_frame_size( self, bytes: usize, ) -> Result<WebSocketUpgrade, WebSocketConfigError>
Sourcepub fn on_upgrade<F, Fut>(self, callback: F) -> Response
pub fn on_upgrade<F, Fut>(self, callback: F) -> Response
Complete the handshake and run callback on the upgraded socket.
Origin is checked here so Self::allowed_origin / Self::any_origin can run first.
§Panics
Panics only if the derived Sec-WebSocket-Accept value is somehow not a
valid header value (should be unreachable for RFC 6455 accept keys).
Trait Implementations§
Source§impl Debug for WebSocketUpgrade
impl Debug for WebSocketUpgrade
Source§impl FromRequest for WebSocketUpgrade
impl FromRequest for WebSocketUpgrade
type Rejection = WebSocketUpgradeRejection
Source§fn from_request(
request: &Request,
) -> Result<WebSocketUpgrade, <WebSocketUpgrade as FromRequest>::Rejection>
fn from_request( request: &Request, ) -> Result<WebSocketUpgrade, <WebSocketUpgrade as FromRequest>::Rejection>
Extract a strongly typed value from a normalized request. Read more
Auto Trait Implementations§
impl !Freeze for WebSocketUpgrade
impl RefUnwindSafe for WebSocketUpgrade
impl Send for WebSocketUpgrade
impl Sync for WebSocketUpgrade
impl Unpin for WebSocketUpgrade
impl UnsafeUnpin for WebSocketUpgrade
impl UnwindSafe for WebSocketUpgrade
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