use std::path::Path;
use crate::{
error::Result,
graph::{Edge, GraphDiff, Node},
schema::NodeKind,
};
pub struct SubGraph {
pub nodes: Vec<Node>,
pub edges: Vec<Edge>,
}
pub struct CallersDeep {
pub hops: Vec<Vec<Node>>,
pub risk_level: &'static str,
}
pub struct SymbolContext {
pub definition: Node,
pub callers: Vec<Node>,
pub callees: Vec<Node>,
pub used_by: Vec<Node>,
}
pub trait GraphStore: Send + Sync {
fn apply_diff(&mut self, branch: &str, diff: &GraphDiff) -> Result<()>;
fn lookup_symbol(&self, branch: &str, name: &str, fuzzy: bool) -> Result<Vec<Node>>;
fn find_callers(&self, branch: &str, function_name: &str) -> Result<Vec<Node>>;
fn find_callers_deep(
&self,
branch: &str,
function_name: &str,
depth: u8,
) -> Result<CallersDeep>;
fn symbol_context(&self, branch: &str, name: &str) -> Result<SymbolContext>;
fn list_definitions(&self, branch: &str, file: &Path) -> Result<Vec<Node>>;
fn list_all_nodes(&self, branch: &str) -> Result<Vec<Node>>;
fn list_all_edges(&self, branch: &str) -> Result<Vec<Edge>>;
fn branch_diff(&self, from: &str, to: &str) -> Result<GraphDiff>;
fn find_callees(&self, branch: &str, function_name: &str, depth: u8) -> Result<CallersDeep>;
fn find_implementors(&self, branch: &str, trait_or_interface_name: &str) -> Result<Vec<Node>>;
fn trace_path(&self, branch: &str, from: &str, to: &str) -> Result<Vec<Node>>;
fn list_symbols_in_range(
&self,
branch: &str,
file: &Path,
start_line: u32,
end_line: u32,
) -> Result<Vec<Node>>;
fn find_unused_symbols(&self, branch: &str, kind: Option<NodeKind>) -> Result<Vec<Node>>;
fn get_subgraph(
&self,
branch: &str,
seed_name: &str,
depth: u8,
direction: &str,
) -> Result<SubGraph>;
fn last_indexed_sha(&self, branch: &str) -> Result<Option<String>>;
fn set_last_indexed_sha(&mut self, branch: &str, sha: &str) -> Result<()>;
}