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
impl PeerTable
Sourcepub fn upsert(
&mut self,
identity: AgentIdentity,
addresses: Vec<TransportAddress>,
)
pub fn upsert( &mut self, identity: AgentIdentity, addresses: Vec<TransportAddress>, )
Add or update a peer in the table.
Sourcepub fn remove(&mut self, id: &Uuid) -> Option<AgentIdentity>
pub fn remove(&mut self, id: &Uuid) -> Option<AgentIdentity>
Remove a peer from the table.
Sourcepub fn get(&self, id: &Uuid) -> Option<&AgentIdentity>
pub fn get(&self, id: &Uuid) -> Option<&AgentIdentity>
Look up a peer’s identity.
Sourcepub fn addresses(&self, id: &Uuid) -> Option<&[TransportAddress]>
pub fn addresses(&self, id: &Uuid) -> Option<&[TransportAddress]>
Get all transport addresses for a peer.
Sourcepub fn all_peers(&self) -> impl Iterator<Item = &AgentIdentity>
pub fn all_peers(&self) -> impl Iterator<Item = &AgentIdentity>
Get all known peers.
Sourcepub fn all_peer_ids(&self) -> impl Iterator<Item = &Uuid>
pub fn all_peer_ids(&self) -> impl Iterator<Item = &Uuid>
Get all known peer IDs.
Sourcepub fn subscribe(&mut self, peer_id: Uuid, topic: impl Into<String>)
pub fn subscribe(&mut self, peer_id: Uuid, topic: impl Into<String>)
Subscribe a peer to a topic.
Sourcepub fn unsubscribe(&mut self, peer_id: &Uuid, topic: &str)
pub fn unsubscribe(&mut self, peer_id: &Uuid, topic: &str)
Unsubscribe a peer from a topic.
Sourcepub fn subscribers(&self, topic: &str) -> Vec<Uuid>
pub fn subscribers(&self, topic: &str) -> Vec<Uuid>
Get all peers subscribed to a topic.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerTable
impl RefUnwindSafe for PeerTable
impl Send for PeerTable
impl Sync for PeerTable
impl Unpin for PeerTable
impl UnsafeUnpin for PeerTable
impl UnwindSafe for PeerTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more