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 new() -> WebSocketRoutes
pub fn new() -> WebSocketRoutes
No routes. Every upgrade is a 404 until something is declared.
Sourcepub fn add(
self,
pattern: impl Into<String>,
handler: impl WebSocketHandler,
) -> WebSocketRoutes
pub fn add( self, pattern: impl Into<String>, handler: impl WebSocketHandler, ) -> WebSocketRoutes
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>,
) -> WebSocketRoutes
pub fn add_arc( self, pattern: impl Into<String>, handler: Arc<dyn WebSocketHandler>, ) -> WebSocketRoutes
Serve a handler you already share.
Sourcepub fn match_path(
&self,
path: &str,
) -> Option<(Arc<dyn WebSocketHandler>, Vec<(String, String)>)>
pub fn match_path( &self, path: &str, ) -> Option<(Arc<dyn WebSocketHandler>, Vec<(String, String)>)>
The handler for path, and whatever its pattern captured.
Trait Implementations§
Source§impl Debug for WebSocketRoutes
impl Debug for WebSocketRoutes
Source§impl Default for WebSocketRoutes
impl Default for WebSocketRoutes
Source§fn default() -> WebSocketRoutes
fn default() -> WebSocketRoutes
Returns the “default value” for a type. Read more
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§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreCreates a shared type from an unshared type.