pub type StoreResult<T> = Result<T, StoreError>;
#[derive(Debug)]
pub enum StoreError {
QueryError(String),
LoadError(String),
ExportError(String),
}
impl std::fmt::Display for StoreError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StoreError::QueryError(msg) => write!(f, "query error: {}", msg),
StoreError::LoadError(msg) => write!(f, "load error: {}", msg),
StoreError::ExportError(msg) => write!(f, "export error: {}", msg),
}
}
}
impl std::error::Error for StoreError {}
pub trait KgStore {
fn load_turtle(&mut self, turtle: &str, graph_name: Option<&str>) -> StoreResult<usize>;
fn sparql_query(&self, sparql: &str) -> StoreResult<String>;
fn sparql_update(&mut self, sparql: &str) -> StoreResult<()>;
fn export_turtle(&self, graph_name: Option<&str>) -> StoreResult<String>;
}