mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Switch RbxValue to an enum
This commit is contained in:
parent
be58598a3e
commit
e1c420d37d
3 changed files with 17 additions and 11 deletions
|
|
@ -3,8 +3,13 @@ use std::collections::HashMap;
|
|||
|
||||
use id::Id;
|
||||
|
||||
// TODO: Switch to enum to represent more value types
|
||||
pub type RbxValue = String;
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum RbxValue {
|
||||
String {
|
||||
value: String,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use id::{Id, get_id};
|
|||
use message_session::{Message, MessageSession};
|
||||
use partition::Partition;
|
||||
use project::Project;
|
||||
use rbx::{RbxInstance, RbxTree};
|
||||
use rbx::{RbxInstance, RbxTree, RbxValue};
|
||||
use vfs_session::{VfsSession, FileItem, FileChange};
|
||||
|
||||
// TODO: Rethink data structure and insertion/update behavior. Maybe break some
|
||||
|
|
@ -51,7 +51,7 @@ fn file_to_instances(
|
|||
};
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert(property_key.to_string(), contents.clone());
|
||||
properties.insert(property_key.to_string(), RbxValue::String { value: contents.clone() });
|
||||
|
||||
tree.insert_instance(primary_id, RbxInstance {
|
||||
name: name.to_string(),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use librojo::{
|
|||
session::Session,
|
||||
project::Project,
|
||||
web::{Server, WebConfig, ServerInfoResponse, ReadResponse, ReadAllResponse, SubscribeResponse},
|
||||
rbx::RbxValue,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
@ -144,7 +145,7 @@ fn one_partition() {
|
|||
module_id = Some(*id);
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert("Source".to_string(), "-- a.lua".to_string());
|
||||
properties.insert("Source".to_string(), RbxValue::String { value: "-- a.lua".to_string() });
|
||||
|
||||
assert_eq!(instance.properties, properties);
|
||||
assert_eq!(instance.parent, Some(partition_id));
|
||||
|
|
@ -162,7 +163,7 @@ fn one_partition() {
|
|||
client_id = Some(*id);
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert("Source".to_string(), "-- b.client.lua".to_string());
|
||||
properties.insert("Source".to_string(), RbxValue::String { value: "-- b.client.lua".to_string() });
|
||||
|
||||
assert_eq!(instance.properties, properties);
|
||||
assert_eq!(instance.parent, Some(partition_id));
|
||||
|
|
@ -180,7 +181,7 @@ fn one_partition() {
|
|||
server_id = Some(*id);
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert("Source".to_string(), "-- a.server.lua".to_string());
|
||||
properties.insert("Source".to_string(), RbxValue::String { value: "-- a.server.lua".to_string() });
|
||||
|
||||
assert_eq!(instance.properties, properties);
|
||||
assert_eq!(instance.parent, Some(partition_id));
|
||||
|
|
@ -277,7 +278,7 @@ fn one_partition() {
|
|||
module_id = Some(*id);
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert("Source".to_string(), "-- a.lua".to_string());
|
||||
properties.insert("Source".to_string(), RbxValue::String { value: "-- a.lua".to_string() });
|
||||
|
||||
assert_eq!(instance.properties, properties);
|
||||
assert_eq!(instance.parent, Some(partition_id));
|
||||
|
|
@ -295,7 +296,7 @@ fn one_partition() {
|
|||
client_id = Some(*id);
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert("Source".to_string(), "-- b.client.lua".to_string());
|
||||
properties.insert("Source".to_string(), RbxValue::String { value: "-- b.client.lua".to_string() });
|
||||
|
||||
assert_eq!(instance.properties, properties);
|
||||
assert_eq!(instance.parent, Some(partition_id));
|
||||
|
|
@ -313,7 +314,7 @@ fn one_partition() {
|
|||
server_id = Some(*id);
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert("Source".to_string(), "-- a.server.lua".to_string());
|
||||
properties.insert("Source".to_string(), RbxValue::String { value: "-- a.server.lua".to_string() });
|
||||
|
||||
assert_eq!(instance.properties, properties);
|
||||
assert_eq!(instance.parent, Some(partition_id));
|
||||
|
|
@ -331,7 +332,7 @@ fn one_partition() {
|
|||
new_id = Some(*id);
|
||||
|
||||
let mut properties = HashMap::new();
|
||||
properties.insert("Source".to_string(), "-- c.client.lua".to_string());
|
||||
properties.insert("Source".to_string(), RbxValue::String { value: "-- c.client.lua".to_string() });
|
||||
|
||||
assert_eq!(instance.properties, properties);
|
||||
assert_eq!(instance.parent, Some(partition_id));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue