Trait Store

Source
pub trait Store {
    // Required methods
    fn get(&self, id: &RepoId) -> Result<HashSet<PublicKey>, Error>;
    fn get_inventory(
        &self,
        node_id: &PublicKey,
    ) -> Result<HashSet<RepoId>, Error>;
    fn entry(
        &self,
        id: &RepoId,
        node: &PublicKey,
    ) -> Result<Option<Timestamp>, Error>;
    fn add_inventory<'a>(
        &mut self,
        ids: impl IntoIterator<Item = &'a RepoId>,
        node: PublicKey,
        time: Timestamp,
    ) -> Result<Vec<(RepoId, InsertResult)>, Error>;
    fn remove_inventory(
        &mut self,
        id: &RepoId,
        node: &PublicKey,
    ) -> Result<bool, Error>;
    fn remove_inventories<'a>(
        &mut self,
        ids: impl IntoIterator<Item = &'a RepoId>,
        node: &PublicKey,
    ) -> Result<(), Error>;
    fn entries(
        &self,
    ) -> Result<Box<dyn Iterator<Item = (RepoId, PublicKey)>>, Error>;
    fn len(&self) -> Result<usize, Error>;
    fn prune(
        &mut self,
        oldest: Timestamp,
        limit: Option<usize>,
        ignore: &PublicKey,
    ) -> Result<usize, Error>;
    fn count(&self, id: &RepoId) -> Result<usize, Error>;

    // Provided method
    fn is_empty(&self) -> Result<bool, Error> { ... }
}
Expand description

Backing store for a routing table.

Required Methods§

Source

fn get(&self, id: &RepoId) -> Result<HashSet<PublicKey>, Error>

Get the nodes seeding the given id.

Source

fn get_inventory(&self, node_id: &PublicKey) -> Result<HashSet<RepoId>, Error>

Get the inventory seeded by the given node.

Source

fn entry( &self, id: &RepoId, node: &PublicKey, ) -> Result<Option<Timestamp>, Error>

Get a specific entry.

Source

fn add_inventory<'a>( &mut self, ids: impl IntoIterator<Item = &'a RepoId>, node: PublicKey, time: Timestamp, ) -> Result<Vec<(RepoId, InsertResult)>, Error>

Add a new node seeding the given id.

Source

fn remove_inventory( &mut self, id: &RepoId, node: &PublicKey, ) -> Result<bool, Error>

Remove an inventory from the given node.

Source

fn remove_inventories<'a>( &mut self, ids: impl IntoIterator<Item = &'a RepoId>, node: &PublicKey, ) -> Result<(), Error>

Remove multiple inventories from the given node.

Source

fn entries( &self, ) -> Result<Box<dyn Iterator<Item = (RepoId, PublicKey)>>, Error>

Iterate over all entries in the routing table.

Source

fn len(&self) -> Result<usize, Error>

Get the total number of routing entries.

Source

fn prune( &mut self, oldest: Timestamp, limit: Option<usize>, ignore: &PublicKey, ) -> Result<usize, Error>

Prune entries older than the given timestamp.

Source

fn count(&self, id: &RepoId) -> Result<usize, Error>

Count the number of routes for a specific repo RID.

Provided Methods§

Source

fn is_empty(&self) -> Result<bool, Error>

Checks if any entries are available.

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§