pub struct TestingWrapper<S: AppState> { /* private fields */ }Expand description
A testing wrapper around the Client that provides comprehensive statistics and monitoring capabilities for WebSocket connections.
Implementations§
Source§impl<S: AppState> TestingWrapper<S>
impl<S: AppState> TestingWrapper<S>
Sourcepub fn new(
client: Client<S>,
runner: ClientRunner<S>,
config: TestingConfig,
) -> Self
pub fn new( client: Client<S>, runner: ClientRunner<S>, config: TestingConfig, ) -> Self
Create a new testing wrapper with the provided client and runner
Sourcepub fn new_with_stats(
client: Client<S>,
runner: ClientRunner<S>,
config: TestingConfig,
stats: Arc<StatisticsTracker>,
) -> Self
pub fn new_with_stats( client: Client<S>, runner: ClientRunner<S>, config: TestingConfig, stats: Arc<StatisticsTracker>, ) -> Self
Create a new testing wrapper with a shared StatisticsTracker This is useful when you want to share statistics between multiple components
Sourcepub fn create_middleware(&self) -> TestingMiddleware<S>
pub fn create_middleware(&self) -> TestingMiddleware<S>
Create a TestingMiddleware that shares the same StatisticsTracker
Sourcepub async fn start(&mut self) -> CoreResult<()>
pub async fn start(&mut self) -> CoreResult<()>
Start the testing wrapper, which will run the client and begin collecting statistics
Sourcepub async fn stop(self) -> CoreResult<ConnectionStats>
pub async fn stop(self) -> CoreResult<ConnectionStats>
Stop the testing wrapper
Sourcepub async fn get_stats(&self) -> ConnectionStats
pub async fn get_stats(&self) -> ConnectionStats
Get the current connection statistics
Sourcepub fn client_mut(&mut self) -> &mut Client<S>
pub fn client_mut(&mut self) -> &mut Client<S>
Get a mutable reference to the underlying client
Sourcepub async fn reset_stats(&self)
pub async fn reset_stats(&self)
Reset all statistics
Sourcepub async fn export_stats_json(&self) -> CoreResult<String>
pub async fn export_stats_json(&self) -> CoreResult<String>
Export statistics to JSON
Sourcepub async fn export_stats_csv(&self) -> CoreResult<String>
pub async fn export_stats_csv(&self) -> CoreResult<String>
Export statistics to CSV
Auto Trait Implementations§
impl<S> Freeze for TestingWrapper<S>
impl<S> !RefUnwindSafe for TestingWrapper<S>
impl<S> Send for TestingWrapper<S>
impl<S> Sync for TestingWrapper<S>
impl<S> Unpin for TestingWrapper<S>
impl<S> UnsafeUnpin for TestingWrapper<S>
impl<S> !UnwindSafe for TestingWrapper<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