pub struct Beacon { /* private fields */ }Expand description
What this node says about itself: the signer plus the advertised facts, with one monotonically increasing sequence shared by every transmitting provider — a reader deduplicates by (instance, seq) regardless of which transport delivered first.
Implementations§
Source§impl Beacon
impl Beacon
Sourcepub fn new(
identity: Arc<NodeIdentity>,
endpoints: Vec<String>,
caps: Vec<String>,
repos: Vec<String>,
version: &str,
) -> Self
pub fn new( identity: Arc<NodeIdentity>, endpoints: Vec<String>, caps: Vec<String>, repos: Vec<String>, version: &str, ) -> Self
A beacon over this node’s identity and advertised facts, for the node’s unnamed
runtime; Beacon::with_runtime names one.
Sourcepub fn with_runtime(self, runtime: &str) -> Self
pub fn with_runtime(self, runtime: &str) -> Self
The same beacon, announcing one runtime slot of the node (16 hex). A node may run a
server per checkout, and a listener that only heard the node could not tell those
apart or address one of them; naming the runtime is what makes an advertisement
answerable by the particular server that sent it. It is a builder step rather than
an argument to Beacon::new because a node with a single unnamed runtime is a
complete configuration.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::provider::Beacon;
let identity = Arc::new(NodeIdentity::ephemeral().unwrap());
let bare = Beacon::new(identity.clone(), vec![], vec![], vec![], "docs");
assert_eq!(bare.runtime(), "", "a node may run one unnamed runtime");
let named = Beacon::new(identity, vec![], vec![], vec![], "docs").with_runtime("0123456789abcdef");
assert_eq!(named.runtime(), "0123456789abcdef");
assert_eq!(named.next_envelope().adv.rt, "0123456789abcdef");Sourcepub fn next_envelope(&self) -> Envelope
pub fn next_envelope(&self) -> Envelope
The next signed envelope, sequence advanced.
Sourcepub fn identity(&self) -> &NodeIdentity
pub fn identity(&self) -> &NodeIdentity
The public identity behind the beacon.