Skip to main content

WebSocketInterceptor

Trait WebSocketInterceptor 

Source
pub trait WebSocketInterceptor:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn intercept<'a>(
        &'a self,
        context: WebSocketContext,
        next: CallHandler<'a, Option<WebSocketMessage>>,
    ) -> BoxFuture<'a, Result<Option<WebSocketMessage>>> { ... }
    fn before(
        &self,
        _context: WebSocketContext,
    ) -> BoxFuture<'static, Result<()>> { ... }
    fn after(
        &self,
        _context: WebSocketContext,
        reply: Option<WebSocketMessage>,
    ) -> BoxFuture<'static, Result<Option<WebSocketMessage>>> { ... }
}
Expand description

Around-handler hook for WebSocket gateway messages.

Provided Methods§

Source

fn intercept<'a>( &'a self, context: WebSocketContext, next: CallHandler<'a, Option<WebSocketMessage>>, ) -> BoxFuture<'a, Result<Option<WebSocketMessage>>>

Run around the remaining WebSocket pipeline.

Override this method to recover downstream errors, retry the handler, or return a reply without calling next. The default implementation preserves the legacy before and after hook behavior.

Source

fn before(&self, _context: WebSocketContext) -> BoxFuture<'static, Result<()>>

Source

fn after( &self, _context: WebSocketContext, reply: Option<WebSocketMessage>, ) -> BoxFuture<'static, Result<Option<WebSocketMessage>>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§