1use crate::{
12 graph::{
13 input::{
14 CreateConfig, CreateEdgeDefConfig, CreateVertexCollConfig, CreateVertexConfig,
15 DeleteConfig, DeleteEdgeDefConfig, DeleteVertexCollConfig, DeleteVertexConfig,
16 EdgeCreateConfig, EdgeDeleteConfig, EdgeReadConfig, EdgeReplaceConfig,
17 EdgeUpdateConfig, ReadConfig, ReadEdgeDefsConfig, ReadVertexCollsConfig,
18 ReadVertexConfig, ReplaceEdgeDefConfig, UpdateVertexConfig,
19 },
20 output::{
21 CreateEdge, DeleteEdge, DeleteVertexMeta, EdgesMeta, GraphMeta, List, ReadEdge,
22 ReadVertexMeta, ReplaceEdge, UpdateEdge, UpdateVertexMeta, VertexColls, VertexMeta,
23 },
24 },
25 ArangoResult,
26};
27use async_trait::async_trait;
28use serde::Serialize;
29
30#[async_trait]
32pub trait Graph {
33 async fn list(&self) -> ArangoResult<List>;
35 async fn create(&self, config: CreateConfig) -> ArangoResult<GraphMeta>;
37 async fn read(&self, config: ReadConfig) -> ArangoResult<GraphMeta>;
39 async fn delete(&self, config: DeleteConfig) -> ArangoResult<()>;
41 async fn create_edge_def(&self, config: CreateEdgeDefConfig) -> ArangoResult<GraphMeta>;
43 async fn read_edge_defs(&self, config: ReadEdgeDefsConfig) -> ArangoResult<EdgesMeta>;
45 async fn delete_edge_def(&self, config: DeleteEdgeDefConfig) -> ArangoResult<GraphMeta>;
47 async fn replace_edge_def(&self, config: ReplaceEdgeDefConfig) -> ArangoResult<GraphMeta>;
49 async fn create_edge(&self, config: EdgeCreateConfig) -> ArangoResult<CreateEdge>;
51 async fn delete_edge(&self, config: EdgeDeleteConfig) -> ArangoResult<DeleteEdge>;
53 async fn read_edge(&self, config: EdgeReadConfig) -> ArangoResult<ReadEdge>;
55 async fn update_edge<T>(&self, config: EdgeUpdateConfig<T>) -> ArangoResult<UpdateEdge>
57 where
58 T: Serialize + Send + Sync;
59 async fn replace_edge<T>(&self, config: EdgeReplaceConfig<T>) -> ArangoResult<ReplaceEdge>
61 where
62 T: Serialize + Send + Sync;
63
64 async fn read_vertex_colls(&self, config: ReadVertexCollsConfig) -> ArangoResult<VertexColls>;
66 async fn create_vertex_coll(&self, config: CreateVertexCollConfig) -> ArangoResult<GraphMeta>;
68 async fn delete_vertex_coll(&self, config: DeleteVertexCollConfig) -> ArangoResult<GraphMeta>;
70 async fn create_vertex<T>(&self, config: CreateVertexConfig<T>) -> ArangoResult<VertexMeta>
72 where
73 T: Serialize + Send + Sync;
74 async fn read_vertex(&self, config: ReadVertexConfig) -> ArangoResult<ReadVertexMeta>;
76 async fn delete_vertex(&self, config: DeleteVertexConfig) -> ArangoResult<DeleteVertexMeta>;
78 async fn update_vertex<T>(
80 &self,
81 config: UpdateVertexConfig<T>,
82 ) -> ArangoResult<UpdateVertexMeta>
83 where
84 T: Serialize + Send + Sync;
85 async fn replace_vertex<T>(
87 &self,
88 config: UpdateVertexConfig<T>,
89 ) -> ArangoResult<UpdateVertexMeta>
90 where
91 T: Serialize + Send + Sync;
92}