Skip to content

Commit

Permalink
Upgrade to rbx_tree and friends 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed Jan 15, 2019
1 parent 14ab85a commit a543646
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
uuid = { version = "0.7", features = ["v4", "serde"] }
rbx_tree = { rev = "8442d57a7a21072a380134962724281d044c65ad", git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_xml = { rev = "8442d57a7a21072a380134962724281d044c65ad", git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_binary = { rev = "8442d57a7a21072a380134962724281d044c65ad", git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_tree = "0.1.0"
rbx_xml = "0.1.0"
rbx_binary = "0.1.0"

[dev-dependencies]
tempfile = "3.0"
Expand Down
9 changes: 9 additions & 0 deletions server/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub enum BuildError {

#[fail(display = "XML model file error")]
XmlModelEncodeError(rbx_xml::EncodeError),

#[fail(display = "Binary model file error")]
BinaryModelEncodeError(rbx_binary::EncodeError)
}

impl From<ProjectLoadFuzzyError> for BuildError {
Expand All @@ -72,6 +75,12 @@ impl From<rbx_xml::EncodeError> for BuildError {
}
}

impl From<rbx_binary::EncodeError> for BuildError {
fn from(error: rbx_binary::EncodeError) -> BuildError {
BuildError::BinaryModelEncodeError(error)
}
}

pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
let output_kind = options.output_kind
.or_else(|| detect_output_kind(options))
Expand Down
6 changes: 3 additions & 3 deletions server/src/rbx_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{

use failure::Fail;

use rbx_tree::{RbxTree, RbxInstance, RbxValue, RbxId};
use rbx_tree::{RbxTree, RbxInstanceProperties, RbxValue, RbxId};

use crate::{
project::{Project, ProjectNode, InstanceProjectNodeMetadata},
Expand Down Expand Up @@ -346,7 +346,7 @@ fn snapshot_xml_model<'a>(
instance_name: Cow<'a, str>,
file: &ImfsFile,
) -> Result<Option<RbxSnapshotInstance<'a>>, SnapshotError> {
let mut temp_tree = RbxTree::new(RbxInstance {
let mut temp_tree = RbxTree::new(RbxInstanceProperties {
name: "Temp".to_owned(),
class_name: "Folder".to_owned(),
properties: HashMap::new(),
Expand Down Expand Up @@ -377,7 +377,7 @@ fn snapshot_binary_model<'a>(
instance_name: Cow<'a, str>,
file: &ImfsFile,
) -> Result<Option<RbxSnapshotInstance<'a>>, SnapshotError> {
let mut temp_tree = RbxTree::new(RbxInstance {
let mut temp_tree = RbxTree::new(RbxInstanceProperties {
name: "Temp".to_owned(),
class_name: "Folder".to_owned(),
properties: HashMap::new(),
Expand Down
8 changes: 4 additions & 4 deletions server/src/rbx_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
path::PathBuf,
};

use rbx_tree::{RbxTree, RbxId, RbxInstance, RbxValue};
use rbx_tree::{RbxTree, RbxId, RbxInstanceProperties, RbxValue};

use crate::{
path_map::PathMap,
Expand Down Expand Up @@ -159,14 +159,14 @@ pub fn reconcile_subtree(
reconcile_instance_children(tree, id, snapshot, path_map, instance_metadata_map, changes);
}

fn reify_core(snapshot: &RbxSnapshotInstance) -> RbxInstance {
fn reify_core(snapshot: &RbxSnapshotInstance) -> RbxInstanceProperties {
let mut properties = HashMap::new();

for (key, value) in &snapshot.properties {
properties.insert(key.clone(), value.clone());
}

let instance = RbxInstance {
let instance = RbxInstanceProperties {
name: snapshot.name.to_string(),
class_name: snapshot.class_name.to_string(),
properties,
Expand All @@ -175,7 +175,7 @@ fn reify_core(snapshot: &RbxSnapshotInstance) -> RbxInstance {
instance
}

fn reconcile_instance_properties(instance: &mut RbxInstance, snapshot: &RbxSnapshotInstance) -> bool {
fn reconcile_instance_properties(instance: &mut RbxInstanceProperties, snapshot: &RbxSnapshotInstance) -> bool {
let mut has_diffs = false;

if instance.name != snapshot.name {
Expand Down
4 changes: 2 additions & 2 deletions server/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rouille::{
Request,
Response,
};
use rbx_tree::{RbxId, RootedRbxInstance};
use rbx_tree::{RbxId, RbxInstance};

use crate::{
session::Session,
Expand All @@ -28,7 +28,7 @@ use crate::{
#[derive(Debug, Serialize, Deserialize)]
pub struct InstanceWithMetadata<'a> {
#[serde(flatten)]
pub instance: Cow<'a, RootedRbxInstance>,
pub instance: Cow<'a, RbxInstance>,

#[serde(rename = "Metadata")]
pub metadata: Option<Cow<'a, InstanceProjectNodeMetadata>>,
Expand Down

0 comments on commit a543646

Please sign in to comment.