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::Encode;
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 [Encode] so that it can be serialized upon broadcast. How a
22        /// received message is decoded is up to the implementation.
23        type Message: Encode + Clone + Send + 'static;
24
25        /// Attempt to broadcast a message to the associated recipients.
26        ///
27        /// Feedback indicates whether the local broadcast request was accepted for processing. It
28        /// does not indicate whether recipients received the message.
29        fn broadcast(&self, recipients: Self::Recipients, message: Self::Message) -> Feedback;
30    }
31});