summaryrefslogtreecommitdiffstats
path: root/src/node.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-06-25 18:55:52 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-06-25 18:55:52 +0200
commit6013177bfc5b3f3ee6b97abe36900fb22e8632e6 (patch)
tree45ffc32781a994f369d9f1a04f043e89b22f3763 /src/node.rs
parent6433a239741acd7f4825d76249509523b86953f7 (diff)
Add minimal required interfaces
Diffstat (limited to 'src/node.rs')
-rw-r--r--src/node.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/node.rs b/src/node.rs
new file mode 100644
index 0000000..b6a088b
--- /dev/null
+++ b/src/node.rs
@@ -0,0 +1,39 @@
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+//
+
+use std::fmt::Debug;
+
+use crate::id::Id;
+
+use futures::future::Future;
+use futures::stream::Stream;
+
+/// A "Node" is an object of the (DA)Graph
+///
+/// In git-speak, this would be an "Object".
+///
+///
+/// # Equality
+///
+/// A node might be compared to another node. In git, for example, equality would be the equality
+/// of the nodes ids, because objects are non-mutable.
+///
+pub trait Node: Debug + PartialEq + Eq {
+ type Id: Id;
+ type NodePayload: Debug;
+ type Error: Debug;
+ type Payload: Future<Item = Self::NodePayload, Error = Self::Error>;
+
+ /// It should be trivial to get the Id of a Node.
+ fn id(&self) -> Self::Id;
+
+ /// Fetch the payload of the node.
+ fn payload(&self) -> Self::Payload;
+
+ /// Fetch the Ids of the parents of this node
+ fn parent_ids(&self) -> Stream<Item = Self::Id, Error = Self::Error>;
+}
+