Skip to main content

commonware_broadcast/
lib.rs

1//! Disseminate data over a wide-area network.
2
3#![doc(
4    html_logo_url = "https://commonware.xyz/imgs/rustdoc_logo.svg",
5    html_favicon_url = "https://commonware.xyz/favicon.ico"
6)]
7
8commonware_macros::stability_scope!(BETA {
9    use commonware_actor::Feedback;
10    use commonware_codec::Codec;
11
12    pub mod buffered;
13
14    /// Broadcaster is the interface responsible for attempting replication of messages across a network.
15    pub trait Broadcaster: Clone + Send + 'static {
16        /// The type of recipients that can receive messages.
17        type Recipients;
18
19        /// Message is the type of data that can be broadcasted.
20        ///
21        /// It must implement the Codec trait so that it can be:
22        /// - serialized upon broadcast
23        /// - deserialized upon reception
24        type Message: Codec + Clone + Send + 'static;
25
26        /// Attempt to broadcast a message to the associated recipients.
27        ///
28        /// Feedback indicates whether the local broadcast request was accepted for processing. It
29        /// does not indicate whether recipients received the message.
30        fn broadcast(&self, recipients: Self::Recipients, message: Self::Message) -> Feedback;
31    }
32});