1use async_trait::async_trait;
6
7use crate::types::{
8 Direction, EdgeExpansion, GraphNode, GraphPayload, GraphSchema, GraphStats, SearchHits,
9};
10
11#[async_trait]
12pub trait GraphProvider: Send + Sync {
13 async fn overview(&self, realm: Option<&str>, limit: usize) -> anyhow::Result<GraphPayload>;
15 async fn node(&self, id: &str) -> anyhow::Result<Option<GraphNode>>;
17 async fn neighbors(
19 &self,
20 ids: &[String],
21 dir: Direction,
22 only_internal: bool,
23 limit: usize,
24 ) -> anyhow::Result<EdgeExpansion>;
25 async fn subgraph(&self, id: &str, depth: usize) -> anyhow::Result<GraphPayload>;
27 async fn search(
30 &self,
31 text: &str,
32 labels: &[String],
33 realm: Option<&str>,
34 limit: usize,
35 offset: usize,
36 ) -> anyhow::Result<SearchHits>;
37 async fn stats(&self, realm: Option<&str>) -> anyhow::Result<GraphStats>;
39 async fn schema(&self) -> anyhow::Result<GraphSchema>;
41}