pub trait LinksStorage<T: LinkReference> {
Show 14 methods
// Required methods
fn create_link(&mut self, source: T, target: T) -> Result<T, LinkError>;
fn ensure_link_created(&mut self, index: T) -> Result<T, LinkError>;
fn get_link(&self, index: T) -> Option<GenericLink<T>>;
fn update_link(
&mut self,
index: T,
source: T,
target: T,
) -> Result<GenericLink<T>, LinkError>;
fn delete_link(&mut self, index: T) -> Result<GenericLink<T>, LinkError>;
fn all_links(&self) -> Vec<GenericLink<T>>;
fn flush(&mut self) -> Result<(), LinkError>;
// Provided methods
fn link_exists(&self, index: T) -> bool { ... }
fn query_links(
&self,
index: Option<T>,
source: Option<T>,
target: Option<T>,
) -> Vec<GenericLink<T>> { ... }
fn search_link(&self, source: T, target: T) -> Option<T> { ... }
fn get_or_create_link(
&mut self,
source: T,
target: T,
) -> Result<T, LinkError> { ... }
fn links_count(&self) -> usize { ... }
fn has_external_changes(&self) -> Result<bool, LinkError> { ... }
fn reload(&mut self) -> Result<(), LinkError> { ... }
}Expand description
A store of links addressed by T, expressed in terms of owned
GenericLink<T> values so that both in-memory maps and
memory-mapped doublets stores can implement it.
Required Methods§
Sourcefn create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
fn create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
Creates a new link and returns its address.
Sourcefn ensure_link_created(&mut self, index: T) -> Result<T, LinkError>
fn ensure_link_created(&mut self, index: T) -> Result<T, LinkError>
Ensures a link exists at index, creating placeholders as needed.
Sourcefn get_link(&self, index: T) -> Option<GenericLink<T>>
fn get_link(&self, index: T) -> Option<GenericLink<T>>
Returns the link stored at index, if any.
Sourcefn update_link(
&mut self,
index: T,
source: T,
target: T,
) -> Result<GenericLink<T>, LinkError>
fn update_link( &mut self, index: T, source: T, target: T, ) -> Result<GenericLink<T>, LinkError>
Repoints index at source/target, returning the previous state.
Sourcefn delete_link(&mut self, index: T) -> Result<GenericLink<T>, LinkError>
fn delete_link(&mut self, index: T) -> Result<GenericLink<T>, LinkError>
Deletes index, returning the link that was removed.
Sourcefn all_links(&self) -> Vec<GenericLink<T>>
fn all_links(&self) -> Vec<GenericLink<T>>
Returns every link in the store.
Sourcefn flush(&mut self) -> Result<(), LinkError>
fn flush(&mut self) -> Result<(), LinkError>
Makes every write durable on disk.
Implementations that keep state in memory write it out here;
memory-mapped implementations fsync the backing file. Callers
that need crash-consistency guarantees must call this — see the
durability notes on each implementation.
Provided Methods§
Sourcefn link_exists(&self, index: T) -> bool
fn link_exists(&self, index: T) -> bool
Returns true when a link exists at index.
Sourcefn query_links(
&self,
index: Option<T>,
source: Option<T>,
target: Option<T>,
) -> Vec<GenericLink<T>>
fn query_links( &self, index: Option<T>, source: Option<T>, target: Option<T>, ) -> Vec<GenericLink<T>>
Returns every link matching the (optional) index/source/target pattern.
Sourcefn search_link(&self, source: T, target: T) -> Option<T>
fn search_link(&self, source: T, target: T) -> Option<T>
Finds the address of a link with the given source and target.
Sourcefn get_or_create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
fn get_or_create_link(&mut self, source: T, target: T) -> Result<T, LinkError>
Returns the address of an existing (source, target) link,
creating it when it does not exist yet.
Sourcefn links_count(&self) -> usize
fn links_count(&self) -> usize
Number of links currently stored.
Sourcefn has_external_changes(&self) -> Result<bool, LinkError>
fn has_external_changes(&self) -> Result<bool, LinkError>
Cheap check for “did another process write to this database since we last read or wrote it?”.
The default implementation reports false, which is correct for
stores that are not shared through the filesystem.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".