use crate::model::{Edge, Node, NodeLabel};
use super::connection::SchemaInitReport;
use super::error::StorageError;
use super::repository::{FunctionRecord, ProjectRecord};
pub trait Storage: Send + Sync {
fn init_schema(&self) -> std::result::Result<SchemaInitReport, StorageError>;
fn execute(&self, cypher: &str) -> std::result::Result<(), StorageError>;
fn query(&self, cypher: &str)
-> std::result::Result<Vec<Vec<serde_json::Value>>, StorageError>;
fn save_project(&self, node: &Node) -> std::result::Result<(), StorageError>;
fn save_nodes(&self, nodes: &[Node], label: NodeLabel)
-> std::result::Result<(), StorageError>;
fn save_edges(&self, edges: &[Edge]) -> std::result::Result<(), StorageError>;
fn get_project(&self, id: &str) -> std::result::Result<Option<ProjectRecord>, StorageError>;
fn list_projects(&self) -> std::result::Result<Vec<ProjectRecord>, StorageError>;
fn query_functions(
&self,
project: &str,
) -> std::result::Result<Vec<FunctionRecord>, StorageError>;
fn get_file_hash(
&self,
file_path: &str,
project: &str,
) -> std::result::Result<Option<String>, StorageError>;
fn get_all_file_hashes(
&self,
project: &str,
) -> std::result::Result<Vec<(String, String)>, StorageError>;
fn delete_project(&self, project_id: &str) -> std::result::Result<(), StorageError>;
fn delete_file_nodes(
&self,
file_path: &str,
project: &str,
) -> std::result::Result<(), StorageError>;
}
#[cfg(test)]
const _: () = {
fn _assert_object_safe(_: &dyn Storage) {}
fn _assert_send_sync<T: Send + Sync + ?Sized>() {}
fn _check() {
_assert_send_sync::<dyn Storage>();
let _ = _assert_object_safe;
}
};