29 lines
733 B
Rust
Raw Normal View History

2025-07-03 16:58:56 -05:00
use thiserror::Error;
2025-07-02 15:31:24 -05:00
use offline_web_model::Reference;
2025-07-03 16:58:56 -05:00
#[derive(Error, Debug)]
pub enum StoreError {
#[error("No such reference")]
NoSuchReference,
#[error("No such content address")]
NoSuchContentAddress,
#[error("Unknown Storage Error: {0:?}")]
StorageError(Box<dyn std::error::Error>),
}
#[allow(async_fn_in_trait)]
pub trait ReferenceStore {
async fn get_reference(&self, id: &str) -> Result<Reference, StoreError>;
async fn get_content_for_reference(&self, reference: Reference) -> Result<String, StoreError>;
2025-07-02 15:31:24 -05:00
2025-07-03 16:58:56 -05:00
async fn get_graph(&self, root_name: &str) -> Result<Vec<Reference>, StoreError>;
}
mod sqlite;
pub use sqlite::SqliteReferenceStore;
2025-07-02 15:31:24 -05:00
2025-07-03 16:58:56 -05:00
#[cfg(test)]
mod integration_tests;