pub struct PeerState { /* private fields */ }Expand description
Tracks the state of connected peers and their connection IDs.
Implementations§
Source§impl PeerState
impl PeerState
pub fn new() -> Self
Sourcepub fn insert(&mut self, peer_id: String, entry: PeerEntry) -> bool
pub fn insert(&mut self, peer_id: String, entry: PeerEntry) -> bool
Register a connected peer. Returns false if already known.
Sourcepub fn remove(&mut self, peer_id: &str) -> Option<PeerEntry>
pub fn remove(&mut self, peer_id: &str) -> Option<PeerEntry>
Remove a peer by ID. Returns the entry if it existed.
Sourcepub fn remove_by_conn(&mut self, conn_id: u64) -> Option<(String, PeerEntry)>
pub fn remove_by_conn(&mut self, conn_id: u64) -> Option<(String, PeerEntry)>
Remove a peer by connection ID (e.g., on unexpected disconnect).
Sourcepub fn contains(&self, peer_id: &str) -> bool
pub fn contains(&self, peer_id: &str) -> bool
Check if a peer is already connected (by peer ID).
Sourcepub fn all_conn_ids(&self) -> Vec<u64>
pub fn all_conn_ids(&self) -> Vec<u64>
Get all peer connection IDs.
Sourcepub fn peer_id_for_conn(&self, conn_id: u64) -> Option<&str>
pub fn peer_id_for_conn(&self, conn_id: u64) -> Option<&str>
Look up a peer_id by connection ID.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerState
impl RefUnwindSafe for PeerState
impl Send for PeerState
impl Sync for PeerState
impl Unpin for PeerState
impl UnsafeUnpin for PeerState
impl UnwindSafe for PeerState
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request