Skip to main content

LinkStore

Trait LinkStore 

Source
pub trait LinkStore {
    // Required methods
    fn create(
        &mut self,
        references: &[LinkId],
        metadata: LinkMetadata,
    ) -> Result<LinkId, StorageError>;
    fn read(&self, id: LinkId) -> Result<Option<Link>, StorageError>;
    fn update(
        &mut self,
        id: LinkId,
        references: &[LinkId],
        metadata: LinkMetadata,
    ) -> Result<bool, StorageError>;
    fn delete(&mut self, id: LinkId) -> Result<bool, StorageError>;
    fn search(&self, query: &LinkStoreQuery) -> Result<Vec<Link>, StorageError>;

    // Provided method
    fn count(&self, query: &LinkStoreQuery) -> Result<usize, StorageError> { ... }
}
Expand description

Storage trait for create/read/update/delete/search over meta-language links.

Required Methods§

Source

fn create( &mut self, references: &[LinkId], metadata: LinkMetadata, ) -> Result<LinkId, StorageError>

Creates a link and returns its stable id.

§Errors

Returns StorageError when the backend cannot write the link.

Source

fn read(&self, id: LinkId) -> Result<Option<Link>, StorageError>

Reads a link by id.

§Errors

Returns StorageError when the backend cannot read its storage.

Source

fn update( &mut self, id: LinkId, references: &[LinkId], metadata: LinkMetadata, ) -> Result<bool, StorageError>

Replaces an existing link’s references and metadata.

§Errors

Returns StorageError when the backend cannot write the update.

Source

fn delete(&mut self, id: LinkId) -> Result<bool, StorageError>

Deletes a link by id.

§Errors

Returns StorageError when the backend cannot delete the link.

Source

fn search(&self, query: &LinkStoreQuery) -> Result<Vec<Link>, StorageError>

Returns links matching query.

§Errors

Returns StorageError when the backend cannot search its storage.

Provided Methods§

Source

fn count(&self, query: &LinkStoreQuery) -> Result<usize, StorageError>

Counts links matching query.

§Errors

Returns StorageError when the backend cannot search its storage.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§