Add builder-ish methods to InstanceSnapshot to make middleware code more readable

This commit is contained in:
Lucien Greathouse
2019-11-19 14:02:57 -08:00
parent 0fbeb70865
commit c3f6a17bae
8 changed files with 115 additions and 87 deletions

View File

@@ -1,7 +1,5 @@
use std::borrow::Cow;
use crate::{
snapshot::InstanceSnapshot,
snapshot::{InstanceMetadata, InstanceSnapshot},
vfs::{Vfs, VfsEntry, VfsFetcher},
};
@@ -36,10 +34,13 @@ impl SnapshotMiddleware for SnapshotRbxlx {
let root_id = temp_tree.get_root_id();
let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, root_id);
snapshot.name = Cow::Owned(instance_name.to_owned());
snapshot.metadata.instigating_source = Some(entry.path().to_path_buf().into());
snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()];
let snapshot = InstanceSnapshot::from_tree(&temp_tree, root_id)
.name(instance_name)
.metadata(InstanceMetadata {
instigating_source: Some(entry.path().to_path_buf().into()),
relevant_paths: vec![entry.path().to_path_buf()],
..Default::default()
});
Ok(Some(snapshot))
}