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.
While this type derives Clone for convenience, it is recommended to use
PeerMap::handle instead to signal that it is a cheap clone.
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 async fn get_ref(&self, peer: PeerId) -> Option<PeerRef>
pub async fn get_ref(&self, peer: PeerId) -> Option<PeerRef>
Retrieve a non-min PeerRef from either the in-memory cache or the session.
Sourcepub fn take(&mut self, peer: PeerId) -> Option<Peer>
pub fn take(&mut self, peer: PeerId) -> Option<Peer>
Take the full Peer object given its PeerId.
The peer will be removed from the map if there are no other strong references to it.
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.