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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! MQTT Message Storage and Retrieval System
//!
//! Provides persistent message storage capabilities with:
//! - Message deduplication tracking
//! - Expiry-based cleanup
//! - Distributed storage coordination
//! - Client-specific message retrieval
//!
//! ## Core Functionality
//! 1. **Message Storage**:
//! - Tracks message origin and metadata
//! - Records subscriber delivery status
//! - Enforces message expiry policies
//!
//! 2. **Message Retrieval**:
//! - Client-specific message queries
//! - Shared subscription support
//! - Optional distributed merge operations
//!
//! 3. **System Monitoring**:
//! - Storage capacity tracking
//! - Message count statistics
//! - Operational status reporting
//!
//! ## Key Features
//! - Pluggable storage backend (default is no-op)
//! - Message ID generation hook
//! - Subscriber state tracking
//! - Cluster-aware storage coordination
//! - Lightweight default implementation
//!
//! ## Implementation Notes
//! - All methods have no-op default implementations
//! - Designed for easy extension with concrete storage backends
//! - Async-compatible interface
//! - Zero-cost when disabled
//!
//! Typical Usage:
//! 1. Implement `store()` for message persistence
//! 2. Override `get()` for client-specific retrieval
//! 3. Implement `merge_on_read()` for cluster coordination
//! 4. Provide capacity monitoring via `count()`/`max()`
//!
//! Note: The default implementation performs no actual storage,
//! making it suitable for brokers that don't require message persistence.
//!
use Duration;
use async_trait;
use crate;
use crateResult;
/// Defines the message storage and retrieval contract for the broker.
///
/// Provides operations for storing, retrieving, and managing MQTT messages
/// with support for message deduplication, expiry-based cleanup, and
/// cluster-aware storage coordination. All methods have no-op default
/// implementations, making the trait easy to implement.
/// A no-op default implementation of [`MessageManager`].
///
/// This implementation performs no actual storage, making it suitable
/// for brokers that do not require message persistence.