pub struct MiddlewareStack<S: AppState> { /* private fields */ }Expand description
A composable stack of middleware layers.
This struct holds a collection of middleware that will be executed in order. Middleware are executed in the order they are added to the stack.
§Example
use binary_options_tools_core_pre::middleware::MiddlewareStack;
let mut stack = MiddlewareStack::new();
stack.add_layer(Box::new(LoggingMiddleware));
stack.add_layer(Box::new(StatisticsMiddleware::new()));Implementations§
Source§impl<S: AppState> MiddlewareStack<S>
impl<S: AppState> MiddlewareStack<S>
Sourcepub fn add_layer(
&mut self,
middleware: Box<dyn WebSocketMiddleware<S> + Send + Sync>,
)
pub fn add_layer( &mut self, middleware: Box<dyn WebSocketMiddleware<S> + Send + Sync>, )
Adds a middleware layer to the stack.
Middleware will be executed in the order they are added.
Sourcepub async fn on_send(&self, message: &Message, context: &MiddlewareContext<S>)
pub async fn on_send(&self, message: &Message, context: &MiddlewareContext<S>)
Sourcepub async fn on_receive(
&self,
message: &Message,
context: &MiddlewareContext<S>,
)
pub async fn on_receive( &self, message: &Message, context: &MiddlewareContext<S>, )
Sourcepub async fn on_connect(&self, context: &MiddlewareContext<S>)
pub async fn on_connect(&self, context: &MiddlewareContext<S>)
Sourcepub async fn on_disconnect(&self, context: &MiddlewareContext<S>)
pub async fn on_disconnect(&self, context: &MiddlewareContext<S>)
Sourcepub async fn record_connection_attempt(&self, context: &MiddlewareContext<S>)
pub async fn record_connection_attempt(&self, context: &MiddlewareContext<S>)
Record a connection attempt across all middleware
Sourcepub async fn record_connection_failure(
&self,
context: &MiddlewareContext<S>,
reason: Option<String>,
)
pub async fn record_connection_failure( &self, context: &MiddlewareContext<S>, reason: Option<String>, )
Record a connection failure across all middleware
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for MiddlewareStack<S>
impl<S> !RefUnwindSafe for MiddlewareStack<S>
impl<S> Send for MiddlewareStack<S>
impl<S> Sync for MiddlewareStack<S>
impl<S> Unpin for MiddlewareStack<S>
impl<S> UnsafeUnpin for MiddlewareStack<S>
impl<S> !UnwindSafe for MiddlewareStack<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