1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: MIT
//! Middleware traits for cross-cutting event interception.
//!
//! Middlewares run **before** listener dispatch and can inspect (or reject) any
//! event flowing through the bus. They receive the event as `&dyn Any`, so a
//! single middleware can handle multiple event types via downcasting.
//!
//! # Ordering
//!
//! Middlewares execute in FIFO registration order. The first middleware to
//! return [`MiddlewareDecision::Reject`] short-circuits the pipeline — no
//! further middlewares run and no listeners are invoked.
use Any;
use Future;
/// Decision returned by a middleware after inspecting an event.
/// Async middleware trait.
///
/// Implement this for middleware that needs to perform async work (e.g., check
/// an external service, acquire a lock, etc.).
/// Sync middleware trait.
///
/// Implement this for lightweight, non-blocking middleware that can make a
/// decision synchronously.