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
//! Service provider trait for dependency injection.
//!
//! The [`DeMlsProvider`] trait bundles all configurable services needed
//! by DE-MLS into a single type parameter. This enables swapping out
//! implementations for testing or custom deployments.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ DeMlsProvider │
//! ├─────────────────────────────────────────────────────────────┤
//! │ Storage │ MLS + DE-MLS state persistence │
//! │ Scope │ Group identifier type (usually String) │
//! │ CStorage │ Consensus proposal/vote persistence │
//! │ EventBus │ Consensus event distribution │
//! │ Consensus │ Voting service (hashgraph-like) │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Default vs Custom Providers
//!
//! Use [`DefaultProvider`] for production deployments:
//! - `MemoryDeMlsStorage` for MLS state storage
//! - `InMemoryConsensusStorage` for proposal/vote storage
//! - `BroadcastEventBus` for consensus event distribution
//! - `DefaultConsensusService` for hashgraph-like voting
//!
//! Create custom providers for:
//! - **Testing**: Mock services that don't require network
//! - **Persistence**: Database-backed storage
//!
//! # Example
//!
//! ```ignore
//! use de_mls::core::{DeMlsProvider, DefaultProvider};
//! use de_mls::app::User;
//!
//! // Production: use DefaultProvider
//! let user: User<DefaultProvider> = User::with_private_key(
//! "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
//! consensus,
//! handler,
//! )?;
//! ```
use ;
use MemoryStorage;
use crate;
/// Bundles all configurable services for a DE-MLS deployment.
///
/// This trait uses associated types to define the concrete implementations
/// of each service. All types must be `Send + Sync + 'static` for async use.
///
/// # Implementing Custom Providers
///
/// ```ignore
/// struct MyProvider;
///
/// impl DeMlsProvider for MyProvider {
/// // Storage backend for MLS state
/// type Storage = SqliteDeMlsStorage;
///
/// // Group identifier (String works for most cases)
/// type Scope = String;
///
/// // Where to store proposals and votes
/// type ConsensusStorage = PostgresConsensusStorage<String>;
///
/// // How to distribute consensus events
/// type EventBus = BroadcastEventBus<String>;
///
/// // The voting service implementation
/// type Consensus = DefaultConsensusService;
/// }
/// ```
/// Default provider for production deployments.
///
/// Uses:
/// - `MemoryDeMlsStorage`: In-memory MLS state storage
/// - `String` scope: Group names as consensus scopes
/// - `InMemoryConsensusStorage`: Fast in-memory proposal/vote storage
/// - `BroadcastEventBus`: Tokio broadcast channels for events
/// - `DefaultConsensusService`: Hashgraph-like voting protocol
///
/// # Example
///
/// ```ignore
/// use de_mls::core::DefaultProvider;
/// use de_mls::app::User;
///
/// let user: User<DefaultProvider> = User::with_private_key(
/// private_key,
/// consensus,
/// handler,
/// )?;
/// ```
;