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
//! Delivery Service — transport-agnostic messaging layer.
//!
//! This module defines the `DeliveryService` trait and its supporting types
//! (`OutboundPacket`, `InboundPacket`, `DeliveryServiceError`), plus a concrete
//! implementation backed by the Waku relay protocol (requires the **`waku`**
//! cargo feature).
//!
//! # Architecture
//!
//! ```text
//! src/ds/
//! ├── transport.rs DeliveryService trait, OutboundPacket, InboundPacket
//! ├── error.rs DeliveryServiceError
//! ├── topic_filter.rs TopicFilter (HashSet-based async allowlist)
//! └── waku/ Waku relay implementation
//! ├── mod.rs WakuDeliveryService, WakuConfig, content-topic helpers
//! ├── sys.rs Raw FFI bindings to libwaku (C trampoline pattern)
//! └── wrapper.rs Safe synchronous WakuNodeCtx wrapper
//! ```
//!
//! # Usage (requires `waku` feature)
//!
//! ```rust,ignore
//! use de_mls::ds::{WakuDeliveryService, WakuConfig, DeliveryService, OutboundPacket};
//!
//! // Start the node — blocks until the embedded Waku node is ready.
//! let result = WakuDeliveryService::start(WakuConfig {
//! node_port: 60000,
//! discv5: true,
//! discv5_udp_port: 61000,
//! ..Default::default()
//! })?;
//!
//! // The local ENR can be passed to other nodes for bootstrapping.
//! if let Some(enr) = &result.enr {
//! println!("Share this ENR with peers: {enr}");
//! }
//!
//! let ds = result.service;
//!
//! // Subscribe to inbound messages (multiple subscribers allowed).
//! let rx = ds.subscribe();
//! std::thread::spawn(move || {
//! while let Ok(pkt) = rx.recv() {
//! println!("got {} bytes for group {}", pkt.payload.len(), pkt.group_id);
//! }
//! });
//!
//! // Send a message.
//! ds.send(OutboundPacket::new(
//! b"hello".to_vec(),
//! "app_msg",
//! "my-group",
//! b"app-instance-id",
//! ))?;
//!
//! // Explicit shutdown (or just drop all clones).
//! ds.shutdown();
//! # Ok::<(), de_mls::ds::DeliveryServiceError>(())
//! ```
//!
//! # Threading model
//!
//! The entire DS layer is **synchronous** — no tokio dependency. The Waku
//! implementation runs an embedded node on a dedicated `std::thread`. Callers
//! in an async context should wrap `DeliveryService::send` in
//! `tokio::task::spawn_blocking`.
/// Protocol version embedded in content topics.
pub const GROUP_VERSION: &str = "1";
/// Subtopic identifier for application messages.
pub const APP_MSG_SUBTOPIC: &str = "app_msg";
/// Subtopic identifier for MLS welcome messages.
pub const WELCOME_SUBTOPIC: &str = "welcome";
/// All subtopics that each group subscribes to.
pub const SUBTOPICS: = ;
pub use DeliveryServiceError;
pub use TopicFilter;
pub use ;
pub use ;