commonware_broadcast/lib.rs
1//! Disseminate data over a wide-area network.
2
3use commonware_codec::Codec;
4use std::future::Future;
5
6pub mod buffered;
7
8/// Broadcaster is the interface responsible for attempting replication of messages across a network.
9pub trait Broadcaster: Clone + Send + 'static {
10 /// Message is the type of data that can be broadcasted.
11 ///
12 /// It must implement the Codec trait so that it can be:
13 /// - serialized upon broadcast
14 /// - deserialized upon reception
15 type Message: Codec + Clone + Send + 'static;
16
17 /// Attempt to broadcast a message to the network.
18 fn broadcast(&mut self, message: Self::Message) -> impl Future<Output = ()> + Send;
19}