diff --git a/src/snapshot/instance_snapshot.rs b/src/snapshot/instance_snapshot.rs index c2b51780..dcd50fe9 100644 --- a/src/snapshot/instance_snapshot.rs +++ b/src/snapshot/instance_snapshot.rs @@ -7,15 +7,13 @@ use serde::{Deserialize, Serialize}; use super::InstanceMetadata; -/// A lightweight description of what an instance should look like. Attempts to -/// be somewhat memory efficient by borrowing from its source data, indicated by -/// the lifetime parameter `'source`. +/// A lightweight description of what an instance should look like. /// // Possible future improvements: // - Use refcounted/interned strings // - Replace use of RbxValue with a sum of RbxValue + borrowed value #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct InstanceSnapshot<'source> { +pub struct InstanceSnapshot { /// A temporary ID applied to the snapshot that's used for Ref properties. pub snapshot_id: Option, @@ -23,10 +21,10 @@ pub struct InstanceSnapshot<'source> { pub metadata: InstanceMetadata, /// Correpsonds to the Name property of the instance. - pub name: Cow<'source, str>, + pub name: Cow<'static, str>, /// Corresponds to the ClassName property of the instance. - pub class_name: Cow<'source, str>, + pub class_name: Cow<'static, str>, /// All other properties of the instance, weakly-typed. pub properties: HashMap, @@ -34,11 +32,11 @@ pub struct InstanceSnapshot<'source> { /// The children of the instance represented as more snapshots. /// /// Order is relevant for Roblox instances! - pub children: Vec>, + pub children: Vec, } -impl<'source> InstanceSnapshot<'source> { - pub fn from_tree(tree: &RbxTree, id: RbxId) -> InstanceSnapshot<'static> { +impl InstanceSnapshot { + pub fn from_tree(tree: &RbxTree, id: RbxId) -> InstanceSnapshot { let instance = tree .get_instance(id) .expect("instance did not exist in tree"); @@ -61,8 +59,8 @@ impl<'source> InstanceSnapshot<'source> { } } -impl<'source> Default for InstanceSnapshot<'source> { - fn default() -> InstanceSnapshot<'source> { +impl Default for InstanceSnapshot { + fn default() -> InstanceSnapshot { InstanceSnapshot { snapshot_id: None, metadata: InstanceMetadata::default(), diff --git a/src/snapshot/patch.rs b/src/snapshot/patch.rs index 8be68c47..6fa1eb29 100644 --- a/src/snapshot/patch.rs +++ b/src/snapshot/patch.rs @@ -13,13 +13,13 @@ use super::{InstanceMetadata, InstanceSnapshot}; /// sure that another patch wasn't applied before this one that could cause a /// conflict! #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchSet<'a> { +pub struct PatchSet { pub removed_instances: Vec, - pub added_instances: Vec>, + pub added_instances: Vec, pub updated_instances: Vec, } -impl<'a> PatchSet<'a> { +impl<'a> PatchSet { pub fn new() -> Self { PatchSet { removed_instances: Vec::new(), @@ -31,9 +31,9 @@ impl<'a> PatchSet<'a> { /// A patch containing an instance that was added to the tree. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchAdd<'a> { +pub struct PatchAdd { pub parent_id: RbxId, - pub instance: InstanceSnapshot<'a>, + pub instance: InstanceSnapshot, } /// A patch indicating that properties of an instance changed. diff --git a/src/snapshot/patch_compute.rs b/src/snapshot/patch_compute.rs index f2405df4..96418d02 100644 --- a/src/snapshot/patch_compute.rs +++ b/src/snapshot/patch_compute.rs @@ -10,11 +10,7 @@ use super::{ InstanceSnapshot, InstanceWithMeta, RojoTree, }; -pub fn compute_patch_set<'a>( - snapshot: &'a InstanceSnapshot, - tree: &RojoTree, - id: RbxId, -) -> PatchSet<'a> { +pub fn compute_patch_set(snapshot: &InstanceSnapshot, tree: &RojoTree, id: RbxId) -> PatchSet { let mut patch_set = PatchSet::new(); let mut context = ComputePatchContext::default(); @@ -69,12 +65,12 @@ fn rewrite_refs_in_snapshot(context: &ComputePatchContext, snapshot: &mut Instan } } -fn compute_patch_set_internal<'a>( +fn compute_patch_set_internal( context: &mut ComputePatchContext, - snapshot: &'a InstanceSnapshot, + snapshot: &InstanceSnapshot, tree: &RojoTree, id: RbxId, - patch_set: &mut PatchSet<'a>, + patch_set: &mut PatchSet, ) { if let Some(snapshot_id) = snapshot.snapshot_id { context.snapshot_id_to_instance_id.insert(snapshot_id, id); @@ -154,12 +150,12 @@ fn compute_property_patches( }); } -fn compute_children_patches<'a>( +fn compute_children_patches( context: &mut ComputePatchContext, - snapshot: &'a InstanceSnapshot, + snapshot: &InstanceSnapshot, tree: &RojoTree, id: RbxId, - patch_set: &mut PatchSet<'a>, + patch_set: &mut PatchSet, ) { let instance = tree .get_instance(id) diff --git a/src/snapshot_middleware/json_model.rs b/src/snapshot_middleware/json_model.rs index 8f1203f3..737c8bf5 100644 --- a/src/snapshot_middleware/json_model.rs +++ b/src/snapshot_middleware/json_model.rs @@ -102,7 +102,7 @@ struct JsonModelCore { } impl JsonModelCore { - fn into_snapshot(self, name: String) -> InstanceSnapshot<'static> { + fn into_snapshot(self, name: String) -> InstanceSnapshot { let class_name = self.class_name; let children = self diff --git a/src/snapshot_middleware/middleware.rs b/src/snapshot_middleware/middleware.rs index f01a9d3a..b77ff15b 100644 --- a/src/snapshot_middleware/middleware.rs +++ b/src/snapshot_middleware/middleware.rs @@ -7,7 +7,7 @@ use crate::{ use super::{context::InstanceSnapshotContext, error::SnapshotError}; -pub type SnapshotInstanceResult<'a> = Result>, SnapshotError>; +pub type SnapshotInstanceResult<'a> = Result, SnapshotError>; pub type SnapshotFileResult = Option<(String, VfsSnapshot)>; pub trait SnapshotMiddleware {