Skip to main content

PeerTable

Struct PeerTable 

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

A table of known peers and their reachable transport addresses.

The peer table is the central data structure for routing decisions. It maps agent UUIDs to their identity and one or more transport addresses through which they can be reached.

Implementations§

Source§

impl PeerTable

Source

pub fn new() -> Self

Create an empty peer table.

Source

pub fn upsert( &mut self, identity: AgentIdentity, addresses: Vec<TransportAddress>, )

Add or update a peer in the table.

Source

pub fn remove(&mut self, id: &Uuid) -> Option<AgentIdentity>

Remove a peer from the table.

Source

pub fn get(&self, id: &Uuid) -> Option<&AgentIdentity>

Look up a peer’s identity.

Source

pub fn addresses(&self, id: &Uuid) -> Option<&[TransportAddress]>

Get all transport addresses for a peer.

Source

pub fn all_peers(&self) -> impl Iterator<Item = &AgentIdentity>

Get all known peers.

Source

pub fn all_peer_ids(&self) -> impl Iterator<Item = &Uuid>

Get all known peer IDs.

Source

pub fn len(&self) -> usize

Number of known peers.

Source

pub fn is_empty(&self) -> bool

Whether the table is empty.

Source

pub fn subscribe(&mut self, peer_id: Uuid, topic: impl Into<String>)

Subscribe a peer to a topic.

Source

pub fn unsubscribe(&mut self, peer_id: &Uuid, topic: &str)

Unsubscribe a peer from a topic.

Source

pub fn subscribers(&self, topic: &str) -> Vec<Uuid>

Get all peers subscribed to a topic.

Trait Implementations§

Source§

impl Debug for PeerTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PeerTable

Source§

fn default() -> PeerTable

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,