PeerStore

Trait PeerStore 

Source
pub trait PeerStore {
    type Error;

    // Required methods
    async fn store_peer(
        &self,
        key: &[u8; 32],
        alias: Option<&[u8]>,
    ) -> Result<(), Self::Error>;
    async fn delete_peer(&self, key: &[u8; 32]) -> Result<(), Self::Error>;
    async fn for_each_peer(
        &self,
        f: &mut dyn FnMut(&[u8; 32], Option<&[u8]>),
    ) -> Result<(), Self::Error>;
}
Expand description

Persistent peer directory for the node layer.

Stores and retrieves peer records keyed by the raw 32-byte Ed25519 public key. alias is an optional UTF-8 label (the implementation may silently truncate values longer than 16 bytes). Implementors MUST treat store_peer as an upsert — calling it twice for the same key overwrites the record.

Required Associated Types§

Required Methods§

Source

async fn store_peer( &self, key: &[u8; 32], alias: Option<&[u8]>, ) -> Result<(), Self::Error>

Upsert the peer record for key. alias, if present, is a UTF-8 display label; passing None removes any existing alias.

Source

async fn delete_peer(&self, key: &[u8; 32]) -> Result<(), Self::Error>

Remove the peer record for key. A no-op if the key is not present.

Source

async fn for_each_peer( &self, f: &mut dyn FnMut(&[u8; 32], Option<&[u8]>), ) -> Result<(), Self::Error>

Invoke f for every persisted peer record.

alias is None when no alias was stored for that key. Callers that cannot handle an error mid-iteration should collect into a local buffer first, then process asynchronously.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§