diff --git a/server/src/rbx_session.rs b/server/src/rbx_session.rs index c697ee7f..ce93d6d7 100644 --- a/server/src/rbx_session.rs +++ b/server/src/rbx_session.rs @@ -6,14 +6,14 @@ use std::{ str, }; -use rbx_tree::{RbxTree, RbxId}; +use rbx_tree::{RbxTree, RbxValue, RbxId}; use crate::{ project::{Project, ProjectNode, InstanceProjectNode}, message_queue::{Message, MessageQueue}, imfs::{Imfs, ImfsItem, ImfsFile}, path_map::PathMap, - rbx_snapshot::{RbxSnapshotInstance, RbxSnapshotValue, reify_root}, + rbx_snapshot::{RbxSnapshotInstance, reify_root}, }; pub struct RbxSession { @@ -216,7 +216,9 @@ fn snapshot_instances_from_imfs<'a>(imfs: &'a Imfs, imfs_path: &Path) -> Option< .expect("File did not contain UTF-8 data, which is required for scripts."); let mut properties = HashMap::new(); - properties.insert(String::from("Source"), RbxSnapshotValue::String(Cow::Borrowed(contents))); + properties.insert(String::from("Source"), RbxValue::String { + value: contents.to_string(), + }); Some(RbxSnapshotInstance { name: Cow::Borrowed(instance_name), diff --git a/server/src/rbx_snapshot.rs b/server/src/rbx_snapshot.rs index f296442e..37e790a0 100644 --- a/server/src/rbx_snapshot.rs +++ b/server/src/rbx_snapshot.rs @@ -10,30 +10,16 @@ use rbx_tree::{RbxTree, RbxId, RbxInstance, RbxValue}; pub struct RbxSnapshotInstance<'a> { pub name: Cow<'a, str>, pub class_name: Cow<'a, str>, - pub properties: HashMap>, + pub properties: HashMap, pub children: Vec>, pub update_trigger_paths: Vec, } -pub enum RbxSnapshotValue<'a> { - String(Cow<'a, str>), -} - -impl<'a> RbxSnapshotValue<'a> { - pub fn to_rbx_value(&self) -> RbxValue { - match self { - RbxSnapshotValue::String(value) => RbxValue::String { - value: value.to_string(), - }, - } - } -} - fn reify_core(snapshot: &RbxSnapshotInstance) -> RbxInstance { let mut properties = HashMap::new(); for (key, value) in &snapshot.properties { - properties.insert(key.clone(), value.to_rbx_value()); + properties.insert(key.clone(), value.clone()); } let instance = RbxInstance { @@ -84,7 +70,7 @@ fn reconcile_instance_properties(instance: &mut RbxInstance, snapshot: &RbxSnaps for (key, instance_value) in &instance.properties { match snapshot.properties.get(key) { Some(snapshot_value) => { - if &snapshot_value.to_rbx_value() != instance_value { + if snapshot_value != instance_value { property_updates.insert(key.clone(), Some(snapshot_value.clone())); } }, @@ -101,7 +87,7 @@ fn reconcile_instance_properties(instance: &mut RbxInstance, snapshot: &RbxSnaps match instance.properties.get(key) { Some(instance_value) => { - if &snapshot_value.to_rbx_value() != instance_value { + if snapshot_value != instance_value { property_updates.insert(key.clone(), Some(snapshot_value.clone())); } }, @@ -115,7 +101,7 @@ fn reconcile_instance_properties(instance: &mut RbxInstance, snapshot: &RbxSnaps for (key, change) in property_updates.drain() { match change { - Some(value) => instance.properties.insert(key, value.to_rbx_value()), + Some(value) => instance.properties.insert(key, value), None => instance.properties.remove(&key), }; }