pub struct PeerMap { /* private fields */ }Expand description
Helper structure to efficiently retrieve peers via their peer.
A lot of responses include the peers related to them in the form of a list of users
and peers, making it annoying to extract a specific peer. This structure lets you
save those separate vectors in a single place and query them by using a Peer.
Implementations§
Source§impl PeerMap
impl PeerMap
Sourcepub fn get(&self, peer: PeerId) -> Option<&Peer>
pub fn get(&self, peer: PeerId) -> Option<&Peer>
Retrieve the full Peer object given its PeerId.
Sourcepub fn remove(&mut self, peer: PeerId) -> Option<Peer>
pub fn remove(&mut self, peer: PeerId) -> Option<Peer>
Take the full Peer object given its PeerId and remove it from the map.
Sourcepub fn iter(&self) -> impl Iterator<Item = (PeerId, &Peer)>
pub fn iter(&self) -> impl Iterator<Item = (PeerId, &Peer)>
Iterate over the peers and peers in the map.
Sourcepub fn iter_peers(&self) -> impl Iterator<Item = &Peer>
pub fn iter_peers(&self) -> impl Iterator<Item = &Peer>
Iterate over the peers in the map.
Auto Trait Implementations§
impl Freeze for PeerMap
impl RefUnwindSafe for PeerMap
impl Send for PeerMap
impl Sync for PeerMap
impl Unpin for PeerMap
impl UnwindSafe for PeerMap
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