summaryrefslogtreecommitdiff
path: root/viz/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'viz/src/lib.rs')
-rw-r--r--viz/src/lib.rs54
1 files changed, 45 insertions, 9 deletions
diff --git a/viz/src/lib.rs b/viz/src/lib.rs
index b40c78a..9a15187 100644
--- a/viz/src/lib.rs
+++ b/viz/src/lib.rs
@@ -15,17 +15,53 @@
extern crate graph;
-pub fn add(left: usize, right: usize) -> usize {
- left + right
+use graph::Graph;
+
+use std::{error::Error, path::Path};
+
+pub mod strong_component;
+
+pub mod decycle;
+
+pub trait Action: Sized {
+ type Karmani: Graph;
+
+ type Error: Error;
+
+ fn perform(&self, obj: &mut Self::Karmani) -> Result<(), Self::Error>;
+
+ fn serialize(&self) -> Vec<u8>;
+ fn deserialize(bytes: impl AsRef<[u8]>) -> Result<Option<(Self, usize)>, Self::Error>;
}
-#[cfg(test)]
-mod tests {
- use super::*;
+#[allow(unused)]
+pub fn serialize<A: Action>(
+ actions: Vec<A>,
+ filename: &Path,
+ final_p: bool,
+) -> Result<(), <A as Action>::Error> {
+ Ok(())
+}
- #[test]
- fn it_works() {
- let result = add(2, 2);
- assert_eq!(result, 4);
+pub fn deserialize<A: Action>(
+ bytes: impl AsRef<[u8]>,
+) -> Result<(Vec<A>, <A as Action>::Karmani), <A as Action>::Error> {
+ let mut bytes = bytes.as_ref();
+
+ let mut result_actions = Vec::new();
+ let mut result_karmanayah = Default::default();
+
+ while let Some((action, offset)) = A::deserialize(bytes)? {
+ action.perform(&mut result_karmanayah)?;
+
+ result_actions.push(action);
+
+ bytes = &bytes[offset..];
}
+
+ let result = (result_actions, result_karmanayah);
+
+ Ok(result)
}
+
+// TODO: Figure out the parts to display graphs.