pub struct TestingMiddleware<S: AppState> { /* private fields */ }Expand description
A testing middleware that tracks connection statistics using the shared StatisticsTracker
Implementations§
Source§impl<S: AppState> TestingMiddleware<S>
impl<S: AppState> TestingMiddleware<S>
Sourcepub fn new(stats: Arc<StatisticsTracker>) -> Self
pub fn new(stats: Arc<StatisticsTracker>) -> Self
Create a new testing middleware with the provided StatisticsTracker
Trait Implementations§
Source§impl<S: AppState> WebSocketMiddleware<S> for TestingMiddleware<S>
impl<S: AppState> WebSocketMiddleware<S> for TestingMiddleware<S>
Source§fn on_connection_attempt<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_connection_attempt<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a connection attempt is made (before actual connection)
Source§fn on_connection_failure<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
reason: Option<String>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_connection_failure<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
reason: Option<String>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a connection attempt fails
Source§fn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a WebSocket connection is established. Read more
Source§fn on_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a WebSocket connection is lost. Read more
Source§fn on_send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 Message,
_context: &'life2 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 Message,
_context: &'life2 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called before a message is sent to the WebSocket. Read more
Source§fn on_receive<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 Message,
_context: &'life2 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_receive<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 Message,
_context: &'life2 MiddlewareContext<S>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after a message is received from the WebSocket. Read more
Auto Trait Implementations§
impl<S> Freeze for TestingMiddleware<S>
impl<S> !RefUnwindSafe for TestingMiddleware<S>
impl<S> Send for TestingMiddleware<S>
impl<S> Sync for TestingMiddleware<S>
impl<S> Unpin for TestingMiddleware<S>where
S: Unpin,
impl<S> UnsafeUnpin for TestingMiddleware<S>
impl<S> !UnwindSafe for TestingMiddleware<S>
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