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§
Sourcefn get(&self, id: &RepoId) -> Result<HashSet<PublicKey>, Error>
fn get(&self, id: &RepoId) -> Result<HashSet<PublicKey>, Error>
Get the nodes seeding the given id.
Sourcefn get_inventory(&self, node_id: &PublicKey) -> Result<HashSet<RepoId>, Error>
fn get_inventory(&self, node_id: &PublicKey) -> Result<HashSet<RepoId>, Error>
Get the inventory seeded by the given node.
Sourcefn entry(
&self,
id: &RepoId,
node: &PublicKey,
) -> Result<Option<Timestamp>, Error>
fn entry( &self, id: &RepoId, node: &PublicKey, ) -> Result<Option<Timestamp>, Error>
Get a specific entry.
Sourcefn add_inventory<'a>(
&mut self,
ids: impl IntoIterator<Item = &'a RepoId>,
node: PublicKey,
time: Timestamp,
) -> Result<Vec<(RepoId, InsertResult)>, Error>
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.
Sourcefn remove_inventory(
&mut self,
id: &RepoId,
node: &PublicKey,
) -> Result<bool, Error>
fn remove_inventory( &mut self, id: &RepoId, node: &PublicKey, ) -> Result<bool, Error>
Remove an inventory from the given node.
Sourcefn remove_inventories<'a>(
&mut self,
ids: impl IntoIterator<Item = &'a RepoId>,
node: &PublicKey,
) -> Result<(), Error>
fn remove_inventories<'a>( &mut self, ids: impl IntoIterator<Item = &'a RepoId>, node: &PublicKey, ) -> Result<(), Error>
Remove multiple inventories from the given node.
Sourcefn entries(
&self,
) -> Result<Box<dyn Iterator<Item = (RepoId, PublicKey)>>, Error>
fn entries( &self, ) -> Result<Box<dyn Iterator<Item = (RepoId, PublicKey)>>, Error>
Iterate over all entries in the routing table.
Provided Methods§
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.