Major Subsystem Rewrite (Reconciler Mk5) (#217)

This commit is contained in:
Lucien Greathouse
2019-08-27 15:00:37 -07:00
committed by GitHub
parent 8e8291a0bd
commit fea303ac8b
80 changed files with 3843 additions and 5609 deletions

View File

@@ -0,0 +1,38 @@
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub enum ImfsSnapshot {
File(FileSnapshot),
Directory(DirectorySnapshot),
}
impl ImfsSnapshot {
/// Create a new file ImfsSnapshot with the given contents.
pub fn file(contents: impl Into<Vec<u8>>) -> ImfsSnapshot {
ImfsSnapshot::File(FileSnapshot {
contents: contents.into(),
})
}
/// Create a new directory ImfsSnapshot with the given children.
pub fn dir<S: Into<String>>(children: HashMap<S, ImfsSnapshot>) -> ImfsSnapshot {
let children = children
.into_iter()
.map(|(k, v)| (k.into(), v))
.collect();
ImfsSnapshot::Directory(DirectorySnapshot {
children,
})
}
}
#[derive(Debug, Clone)]
pub struct FileSnapshot {
pub contents: Vec<u8>,
}
#[derive(Debug, Clone)]
pub struct DirectorySnapshot {
pub children: HashMap<String, ImfsSnapshot>,
}