assert_graph_iso/
graph.rs1use std::{
2 fmt::{Debug, Display},
3 hash::Hash,
4};
5
6pub type NodesIterator<'a, T> = Box<dyn Iterator<Item = T> + 'a>;
7pub type LabelIterator<'a, T> = Box<dyn Iterator<Item = T> + 'a>;
8pub type PropertyIterator<'a, K, V> = Box<dyn Iterator<Item = (K, V)> + 'a>;
9
10pub trait Graph {
11 type NodeId: Debug + Hash + Eq + ?Sized;
12
13 type NodeLabel: Display + ?Sized;
14
15 type RelationshipType: Display + ?Sized;
16
17 type PropertyKey: Display + ?Sized;
18
19 type PropertyValue: Display + ?Sized;
20
21 fn nodes(&self) -> NodesIterator<&Self::NodeId>;
22
23 fn node_labels(&self, node_id: &Self::NodeId) -> LabelIterator<&Self::NodeLabel>;
24
25 fn node_properties(
26 &self,
27 node_id: &Self::NodeId,
28 ) -> PropertyIterator<&Self::PropertyKey, &Self::PropertyValue>;
29
30 fn outgoing_relationships<'a, 'b: 'a>(
31 &'a self,
32 node_id: &'b Self::NodeId,
33 ) -> PropertyIterator<
34 (&'a Self::NodeId, &'a Self::RelationshipType),
35 PropertyIterator<&'a Self::PropertyKey, &'a Self::PropertyValue>,
36 >;
37
38 fn incoming_relationships<'a, 'b: 'a>(
39 &'a self,
40 node_id: &'b Self::NodeId,
41 ) -> PropertyIterator<
42 (&'a Self::NodeId, &'a Self::RelationshipType),
43 PropertyIterator<&'a Self::PropertyKey, &'a Self::PropertyValue>,
44 >;
45}