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},
};
@@ -38,10 +36,13 @@ impl SnapshotMiddleware for SnapshotRbxmx {
let children = root_instance.get_children_ids();
if children.len() == 1 {
let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, children[0]);
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, children[0])
.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))
} else {