Struct network::application::storage::PeerMetadataStorage
source · [−]pub struct PeerMetadataStorage { /* private fields */ }Expand description
Metadata storage for peers across all of networking. Splits storage of information across networks to prevent different networks from affecting each other
Implementations
sourceimpl PeerMetadataStorage
impl PeerMetadataStorage
sourcepub fn new(network_ids: &[NetworkId]) -> Arc<PeerMetadataStorage>
pub fn new(network_ids: &[NetworkId]) -> Arc<PeerMetadataStorage>
Create a new PeerMetadataStorage NetworkIds must be known at construction time
pub fn networks(&self) -> impl Iterator<Item = NetworkId> + '_
pub fn read(&self, peer_network_id: PeerNetworkId) -> Option<PeerInfo>
pub fn read_filtered<F: FnMut(&(&PeerId, &PeerInfo)) -> bool>(
&self,
network_id: NetworkId,
filter: F
) -> HashMap<PeerNetworkId, PeerInfo>
pub fn keys(&self, network_id: NetworkId) -> Vec<PeerNetworkId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn read_all(&self, network_id: NetworkId) -> HashMap<PeerNetworkId, PeerInfo>
pub fn read_all(&self, network_id: NetworkId) -> HashMap<PeerNetworkId, PeerInfo>
Read a clone of the entire state
sourcepub fn insert(&self, peer_network_id: PeerNetworkId, new_value: PeerInfo)
pub fn insert(&self, peer_network_id: PeerNetworkId, new_value: PeerInfo)
Insert new entry
sourcepub fn remove(&self, peer_network_id: &PeerNetworkId)
pub fn remove(&self, peer_network_id: &PeerNetworkId)
Remove old entries
sourcepub fn write<F: FnOnce(&mut Entry<'_, PeerId, PeerInfo>) -> Result<(), PeerError>>(
&self,
peer_network_id: PeerNetworkId,
modifier: F
) -> Result<(), PeerError>
pub fn write<F: FnOnce(&mut Entry<'_, PeerId, PeerInfo>) -> Result<(), PeerError>>(
&self,
peer_network_id: PeerNetworkId,
modifier: F
) -> Result<(), PeerError>
Take in a function to modify the data, must handle concurrency control with the input function
sourcepub fn write_lock(
&self,
network_id: NetworkId
) -> RwLockWriteGuard<'_, HashMap<PeerId, PeerInfo>>
pub fn write_lock(
&self,
network_id: NetworkId
) -> RwLockWriteGuard<'_, HashMap<PeerId, PeerInfo>>
Get the underlying RwLock of the map. Usage is discouraged as it leads to the possiblity of
leaving the lock held for a long period of time. However, not everything fits into the write
model.
pub fn insert_connection(
&self,
network_id: NetworkId,
connection_metadata: ConnectionMetadata
)
pub fn remove_connection(
&self,
network_id: NetworkId,
connection_metadata: &ConnectionMetadata
)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PeerMetadataStorage
impl Send for PeerMetadataStorage
impl Sync for PeerMetadataStorage
impl Unpin for PeerMetadataStorage
impl UnwindSafe for PeerMetadataStorage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more