mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-26 15:46:28 +00:00
Make SnapshotMiddleware::from_instance have a default impl
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
use std::{borrow::Cow, collections::BTreeMap};
|
use std::{borrow::Cow, collections::BTreeMap};
|
||||||
|
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use rbx_dom_weak::{RbxId, RbxTree, RbxValue};
|
use rbx_dom_weak::RbxValue;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,10 +62,6 @@ impl SnapshotMiddleware for SnapshotCsv {
|
|||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
|
||||||
unimplemented!("Snapshotting CSV localization tables");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Struct that holds any valid row from a Roblox CSV translation table.
|
/// Struct that holds any valid row from a Roblox CSV translation table.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{borrow::Cow, collections::HashMap};
|
use std::{borrow::Cow, collections::HashMap};
|
||||||
|
|
||||||
use rbx_dom_weak::{RbxId, RbxTree, UnresolvedRbxValue};
|
use rbx_dom_weak::UnresolvedRbxValue;
|
||||||
use rbx_reflection::try_resolve_value;
|
use rbx_reflection::try_resolve_value;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,10 +58,6 @@ impl SnapshotMiddleware for SnapshotJsonModel {
|
|||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
|
||||||
unimplemented!("Snapshotting models");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_trailing<'a>(input: &'a str, trailer: &str) -> Option<&'a str> {
|
fn match_trailing<'a>(input: &'a str, trailer: &str) -> Option<&'a str> {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::{borrow::Cow, str};
|
use std::{borrow::Cow, str};
|
||||||
|
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use rbx_dom_weak::{RbxId, RbxTree, RbxValue};
|
use rbx_dom_weak::RbxValue;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{FsResultExt, Imfs, ImfsEntry, ImfsFetcher},
|
imfs::{FsResultExt, Imfs, ImfsEntry, ImfsFetcher},
|
||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
use super::{
|
use super::{
|
||||||
dir::SnapshotDir,
|
dir::SnapshotDir,
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_trailing,
|
util::match_trailing,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,17 +48,6 @@ impl SnapshotMiddleware for SnapshotLua {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(tree: &RbxTree, id: RbxId) -> SnapshotFileResult {
|
|
||||||
let instance = tree.get_instance(id).unwrap();
|
|
||||||
|
|
||||||
match instance.class_name.as_str() {
|
|
||||||
"ModuleScript" | "LocalScript" | "Script" => {
|
|
||||||
unimplemented!("Snapshotting Script instances")
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Core routine for turning Lua files into snapshots.
|
/// Core routine for turning Lua files into snapshots.
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ pub trait SnapshotMiddleware {
|
|||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static>;
|
) -> SnapshotInstanceResult<'static>;
|
||||||
|
|
||||||
fn from_instance(tree: &RbxTree, id: RbxId) -> SnapshotFileResult;
|
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
fn change_affects_paths(path: &Path) -> Vec<PathBuf> {
|
fn change_affects_paths(path: &Path) -> Vec<PathBuf> {
|
||||||
vec![path.to_path_buf()]
|
vec![path.to_path_buf()]
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::{borrow::Cow, collections::HashMap};
|
use std::{borrow::Cow, collections::HashMap};
|
||||||
|
|
||||||
use rbx_dom_weak::{RbxId, RbxTree};
|
|
||||||
use rbx_reflection::try_resolve_value;
|
use rbx_reflection::try_resolve_value;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -11,7 +10,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
error::SnapshotError,
|
error::SnapshotError,
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
snapshot_from_imfs,
|
snapshot_from_imfs,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,11 +71,6 @@ impl SnapshotMiddleware for SnapshotProject {
|
|||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
|
||||||
// TODO: Supporting turning instances into projects
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_project_node<F: ImfsFetcher>(
|
fn snapshot_project_node<F: ImfsFetcher>(
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use rbx_dom_weak::{RbxId, RbxTree};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{Imfs, ImfsEntry, ImfsFetcher},
|
imfs::{Imfs, ImfsEntry, ImfsFetcher},
|
||||||
snapshot::InstanceSnapshot,
|
snapshot::InstanceSnapshot,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,8 +41,4 @@ impl SnapshotMiddleware for SnapshotRbxlx {
|
|||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{borrow::Cow, collections::HashMap};
|
use std::{borrow::Cow, collections::HashMap};
|
||||||
|
|
||||||
use rbx_dom_weak::{RbxId, RbxInstanceProperties, RbxTree};
|
use rbx_dom_weak::{RbxInstanceProperties, RbxTree};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{Imfs, ImfsEntry, ImfsFetcher},
|
imfs::{Imfs, ImfsEntry, ImfsFetcher},
|
||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,10 +52,6 @@ impl SnapshotMiddleware for SnapshotRbxm {
|
|||||||
panic!("Rojo doesn't have support for model files with zero or more than one top-level instances yet.");
|
panic!("Rojo doesn't have support for model files with zero or more than one top-level instances yet.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
|
||||||
unimplemented!("Snapshotting models");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use rbx_dom_weak::{RbxId, RbxTree};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{Imfs, ImfsEntry, ImfsFetcher},
|
imfs::{Imfs, ImfsEntry, ImfsFetcher},
|
||||||
snapshot::InstanceSnapshot,
|
snapshot::InstanceSnapshot,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,10 +46,6 @@ impl SnapshotMiddleware for SnapshotRbxmx {
|
|||||||
panic!("Rojo doesn't have support for model files with zero or more than one top-level instances yet.");
|
panic!("Rojo doesn't have support for model files with zero or more than one top-level instances yet.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
|
||||||
unimplemented!("Snapshotting models");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user