pub struct WebSocketRoutes { /* private fields */ }Expand description
The WebSocket routes an application declares — routes/ws.rs.
Separate from the HTTP router because the two answer different things: an HTTP route returns a response and is done, a socket route starts a conversation. Sharing one table would mean one of them pretending.
ⓘ
pub fn routes() -> WebSocketRoutes {
WebSocketRoutes::new()
.add("/ws/rooms/{room}", Chat::new(rooms))
.add("/ws/notifications", Notifications)
}Implementations§
Source§impl WebSocketRoutes
impl WebSocketRoutes
Sourcepub fn add(
self,
pattern: impl Into<String>,
handler: impl WebSocketHandler,
) -> Self
pub fn add( self, pattern: impl Into<String>, handler: impl WebSocketHandler, ) -> Self
Serve handler at pattern.
{name} captures a segment, readable from
Socket::param. The first matching pattern
wins, so declare the specific before the general.
Sourcepub fn add_arc(
self,
pattern: impl Into<String>,
handler: Arc<dyn WebSocketHandler>,
) -> Self
pub fn add_arc( self, pattern: impl Into<String>, handler: Arc<dyn WebSocketHandler>, ) -> Self
Serve a handler you already share.
Sourcepub fn match_path(&self, path: &str) -> Option<Matched>
pub fn match_path(&self, path: &str) -> Option<Matched>
The handler for path, and whatever its pattern captured.
Trait Implementations§
Source§impl Debug for WebSocketRoutes
impl Debug for WebSocketRoutes
Auto Trait Implementations§
impl !RefUnwindSafe for WebSocketRoutes
impl !UnwindSafe for WebSocketRoutes
impl Freeze for WebSocketRoutes
impl Send for WebSocketRoutes
impl Sync for WebSocketRoutes
impl Unpin for WebSocketRoutes
impl UnsafeUnpin for WebSocketRoutes
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