Skip to main content

MeshRegistry

Struct MeshRegistry 

Source
pub struct MeshRegistry { /* private fields */ }
Expand description

The registry. Mutex<BTreeMap>, like the peer board: contention is a handful of datagrams a second, and a deterministic order falls out for free.

Implementations§

Source§

impl MeshRegistry

Source

pub fn new() -> Self

An empty registry; it fills only through MeshRegistry::observe.

Source

pub fn known_key(&self, node: &NodeId) -> Option<String>

The key currently bound to a node id, for trust evaluation.

Source

pub fn trust_of(&self, node: &NodeId) -> Option<TrustState>

The current trust state of a node id: the one its runtimes share, the first rejection winning, because trust is a property of the key and not of a server.

Source

pub fn observe( &self, adv: &Advertisement, node_id: NodeId, trust: TrustState, source: MeshSource, path: &str, raw: Value, ) -> bool

Record one verified observation; raw is the envelope as heard, kept verbatim for rendezvous answers. Returns false when the datagram was a replay (same instance, sequence not above the highest seen) and the record was left unchanged.

Source

pub fn candidates_for(&self, limit: usize, repos: &[String]) -> Vec<Value>

The envelopes of present, trusted nodes that serve one of repos, verbatim as heard, at most limit: what a rendezvous answers a registered caller with. A caller learns only the nodes of its own repository this node trusts — never the topology of another repository or the strangers this node merely observed (I2133).

use majordomus_cli::mesh::MeshRegistry;
let empty = MeshRegistry::new();
assert!(empty.candidates_for(32, &["r1".into()]).is_empty());
Source

pub fn list(&self) -> Vec<NodeRecord>

Every record, in node-id order, presence recomputed against now.

Source

pub fn tallies(&self) -> Tallies

The tallies, presence recomputed against now.

Trait Implementations§

Source§

impl Default for MeshRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more