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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Subscription lifecycle hooks.
//!
//! The [`SubscriptionLifecycle`] trait provides callbacks invoked at key points
//! in the `WebSocket` subscription lifecycle. Implementations can perform
//! authentication, rate limiting, audit logging, or custom authorisation.
use async_trait;
/// Callbacks for subscription lifecycle events.
///
/// All methods have default no-op implementations, so you only need to
/// override the hooks you care about.
///
/// # Fail-closed vs fire-and-forget
///
/// - `on_connect` / `on_subscribe` are **fail-closed**: returning `Err(reason)` rejects the
/// connection or subscription.
/// - `on_disconnect` / `on_unsubscribe` are **fire-and-forget**: the connection is already closing
/// and there is nothing to reject.
// Reason: used as dyn Trait (Arc<dyn SubscriptionLifecycle>); async_trait ensures Send bounds and
// dyn-compatibility async_trait: dyn-dispatch required; remove when RTN + Send is stable (RFC 3425)
/// No-op lifecycle that accepts everything.
;
// Reason: SubscriptionLifecycle is defined with #[async_trait]; all implementations must match
// its transformed method signatures to satisfy the trait contract
// async_trait: dyn-dispatch required; remove when RTN + Send is stable (RFC 3425)