Skip to main content

crdt_graph/types/
mod.rs

1use crate::graph::{TwoPTwoPId, TwoPTwoPRemoveEdge, TwoPTwoPRemoveVertex};
2use uuid::Uuid;
3
4pub mod bytes;
5pub mod simple;
6pub mod string;
7
8// ===========================================================================
9// Shared remove-operation types (identical across all graph variants)
10// ===========================================================================
11
12/// A vertex-remove operation. Only references the original add by ID.
13#[derive(Clone, Debug, PartialEq, Eq, Hash)]
14pub struct RemoveVertex {
15    pub id: Uuid,
16    pub add_vertex_id: Uuid,
17}
18
19impl TwoPTwoPId<Uuid> for RemoveVertex {
20    fn id(&self) -> &Uuid {
21        &self.id
22    }
23}
24
25impl TwoPTwoPRemoveVertex<Uuid> for RemoveVertex {
26    fn add_vertex_id(&self) -> &Uuid {
27        &self.add_vertex_id
28    }
29}
30
31/// An edge-remove operation. Only references the original add by ID.
32#[derive(Clone, Debug, PartialEq, Eq, Hash)]
33pub struct RemoveEdge {
34    pub id: Uuid,
35    pub add_edge_id: Uuid,
36}
37
38impl TwoPTwoPId<Uuid> for RemoveEdge {
39    fn id(&self) -> &Uuid {
40        &self.id
41    }
42}
43
44impl TwoPTwoPRemoveEdge<Uuid> for RemoveEdge {
45    fn add_edge_id(&self) -> &Uuid {
46        &self.add_edge_id
47    }
48}