Upgrade to rbx_tree and friends 0.1.0

This commit is contained in:
Lucien Greathouse
2019-01-14 18:21:01 -08:00
parent 14ab85adbd
commit a54364642a
6 changed files with 32 additions and 23 deletions

View File

@@ -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 {
@@ -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))

View File

@@ -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},
@@ -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(),
@@ -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(),

View File

@@ -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,
@@ -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,
@@ -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 {

View File

@@ -10,7 +10,7 @@ use rouille::{
Request,
Response,
};
use rbx_tree::{RbxId, RootedRbxInstance};
use rbx_tree::{RbxId, RbxInstance};
use crate::{
session::Session,
@@ -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>>,