pub struct WebSocketGatewayDefinition { /* private fields */ }Expand description
Framework-neutral WebSocket gateway definition.
Implementations§
Source§impl WebSocketGatewayDefinition
impl WebSocketGatewayDefinition
pub fn new(path: impl Into<String>) -> Result<Self>
pub fn path(&self) -> &str
pub fn path_shape(&self) -> String
pub fn module_name(&self) -> Option<&str>
pub fn namespace(&self) -> Option<&str>
pub fn metadata(&self) -> &BTreeMap<String, Value>
pub fn metadata_value(&self, key: &str) -> Option<&Value>
pub fn event_metadata(&self, event: &str) -> Option<&BTreeMap<String, Value>>
pub fn with_metadata<V>(self, key: impl Into<String>, value: V) -> Result<Self>where
V: Serialize,
pub fn with_metadata_value(self, key: impl Into<String>, value: Value) -> Self
pub fn with_namespace(self, namespace: impl Into<String>) -> Result<Self>
pub fn events(&self) -> Vec<&str>
pub fn server(&self) -> WebSocketGatewayServer
pub fn active_connection_count(&self) -> Result<usize>
pub fn active_connection_ids(&self) -> Result<Vec<u64>>
pub fn rooms(&self) -> Result<Vec<String>>
pub fn room_members(&self, room: impl Into<String>) -> Result<Vec<u64>>
pub async fn broadcast(&self, message: WebSocketMessage) -> Result<usize>
pub async fn broadcast_to_room( &self, room: impl Into<String>, message: WebSocketMessage, ) -> Result<usize>
Sourcepub async fn after_init(&self) -> Result<()>
pub async fn after_init(&self) -> Result<()>
Run gateway initialization hooks.
pub fn matches_path(&self, path: &str) -> bool
pub fn path_params( &self, path: &str, ) -> Result<Option<BTreeMap<String, String>>>
pub fn subscribe<H, Fut, R>(
self,
event: impl Into<String>,
handler: H,
) -> Result<Self>where
H: Fn(WebSocketMessage) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<R>> + Send + 'static,
R: IntoWebSocketReply + Send + 'static,
pub fn subscribe_with_connection<H, Fut, R>(
self,
event: impl Into<String>,
handler: H,
) -> Result<Self>where
H: Fn(WebSocketGatewayConnection, WebSocketMessage) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<R>> + Send + 'static,
R: IntoWebSocketReply + Send + 'static,
pub fn subscribe_with_server<H, Fut, R>(
self,
event: impl Into<String>,
handler: H,
) -> Result<Self>where
H: Fn(WebSocketGatewayServer, WebSocketMessage) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<R>> + Send + 'static,
R: IntoWebSocketReply + Send + 'static,
pub fn subscribe_definition( self, event: impl Into<String>, subscription: WebSocketSubscriptionDefinition, ) -> Result<Self>
pub fn with_after_init<H>(self, hook: H) -> Selfwhere
H: WebSocketGatewayInitHook,
pub fn with_connection_hook<H>(self, hook: H) -> Selfwhere
H: WebSocketGatewayConnectionHook,
pub fn with_disconnect_hook<H>(self, hook: H) -> Selfwhere
H: WebSocketGatewayDisconnectHook,
pub fn with_pipe<P>(self, pipe: P) -> Selfwhere
P: WebSocketPipe,
pub fn with_guard<G>(self, guard: G) -> Selfwhere
G: WebSocketGuard,
pub fn with_execution_guard<G>(self, guard: G) -> Selfwhere
G: Guard,
pub fn with_interceptor<I>(self, interceptor: I) -> Selfwhere
I: WebSocketInterceptor,
pub fn with_execution_interceptor<I>(self, interceptor: I) -> Selfwhere
I: ExecutionInterceptor,
pub fn with_filter<F>(self, filter: F) -> Selfwhere
F: WebSocketExceptionFilter,
pub fn with_catch_filter<I, F>(self, kinds: I, filter: F) -> Self
pub fn connect( &self, request: BootRequest, ) -> Result<WebSocketGatewayConnection>
pub fn connect_with_outbound<O>(
&self,
request: BootRequest,
outbound: O,
) -> Result<WebSocketGatewayConnection>where
O: WebSocketOutbound,
pub async fn connect_async( &self, request: BootRequest, ) -> Result<WebSocketGatewayConnection>
pub async fn connect_async_with_outbound<O>(
&self,
request: BootRequest,
outbound: O,
) -> Result<WebSocketGatewayConnection>where
O: WebSocketOutbound,
pub async fn emit_to_connection( &self, connection_id: u64, message: WebSocketMessage, ) -> Result<bool>
pub async fn dispatch( &self, request: BootRequest, message: WebSocketMessage, ) -> Result<Option<WebSocketMessage>>
Trait Implementations§
Source§impl Clone for WebSocketGatewayDefinition
impl Clone for WebSocketGatewayDefinition
Source§fn clone(&self) -> WebSocketGatewayDefinition
fn clone(&self) -> WebSocketGatewayDefinition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for WebSocketGatewayDefinition
impl !UnwindSafe for WebSocketGatewayDefinition
impl Freeze for WebSocketGatewayDefinition
impl Send for WebSocketGatewayDefinition
impl Sync for WebSocketGatewayDefinition
impl Unpin for WebSocketGatewayDefinition
impl UnsafeUnpin for WebSocketGatewayDefinition
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