mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 23:26:19 +00:00
Thread InstanceSnapshotContext through all SnapshotMiddleware
This commit is contained in:
@@ -1,7 +1,16 @@
|
|||||||
|
#[derive(Debug)]
|
||||||
pub struct InstanceSnapshotContext {
|
pub struct InstanceSnapshotContext {
|
||||||
/// Empty struct that will be used later to fill out required Lua state for
|
/// Empty struct that will be used later to fill out required Lua state for
|
||||||
/// user plugins.
|
/// user plugins.
|
||||||
pub plugin_context: Option<()>,
|
pub plugin_context: Option<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for InstanceSnapshotContext {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
plugin_context: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct ImfsSnapshotContext;
|
pub struct ImfsSnapshotContext;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
@@ -19,6 +20,7 @@ pub struct SnapshotCsv;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotCsv {
|
impl SnapshotMiddleware for SnapshotCsv {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
_context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -159,7 +161,10 @@ Ack,Ack!,,An exclamation of despair,¡Ay!"#,
|
|||||||
imfs.debug_load_snapshot("/foo.csv", file);
|
imfs.debug_load_snapshot("/foo.csv", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.csv").unwrap();
|
let entry = imfs.get("/foo.csv").unwrap();
|
||||||
let instance_snapshot = SnapshotCsv::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotCsv::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
@@ -178,7 +183,10 @@ Ack,Ack!,,An exclamation of despair,¡Ay!"#,
|
|||||||
imfs.debug_load_snapshot("/foo.meta.json", meta);
|
imfs.debug_load_snapshot("/foo.meta.json", meta);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.csv").unwrap();
|
let entry = imfs.get("/foo.csv").unwrap();
|
||||||
let instance_snapshot = SnapshotCsv::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotCsv::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
error::SnapshotError,
|
error::SnapshotError,
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
snapshot_from_imfs, snapshot_from_instance,
|
snapshot_from_imfs, snapshot_from_instance,
|
||||||
@@ -17,6 +18,7 @@ pub struct SnapshotDir;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotDir {
|
impl SnapshotMiddleware for SnapshotDir {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
_context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -94,7 +96,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotDir::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotDir::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
@@ -109,7 +114,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotDir::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotDir::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -18,6 +19,7 @@ pub struct SnapshotJsonModel;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotJsonModel {
|
impl SnapshotMiddleware for SnapshotJsonModel {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
_context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -161,7 +163,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.model.json", file);
|
imfs.debug_load_snapshot("/foo.model.json", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.model.json").unwrap();
|
let entry = imfs.get("/foo.model.json").unwrap();
|
||||||
let instance_snapshot = SnapshotJsonModel::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotJsonModel::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
dir::SnapshotDir,
|
dir::SnapshotDir,
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
@@ -19,6 +20,7 @@ pub struct SnapshotLua;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotLua {
|
impl SnapshotMiddleware for SnapshotLua {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -34,13 +36,13 @@ impl SnapshotMiddleware for SnapshotLua {
|
|||||||
if entry.is_file() {
|
if entry.is_file() {
|
||||||
snapshot_lua_file(imfs, entry)
|
snapshot_lua_file(imfs, entry)
|
||||||
} else {
|
} else {
|
||||||
if let Some(snapshot) = snapshot_init(imfs, entry, "init.lua")? {
|
if let Some(snapshot) = snapshot_init(context, imfs, entry, "init.lua")? {
|
||||||
// An `init.lua` file turns its parent into a ModuleScript
|
// An `init.lua` file turns its parent into a ModuleScript
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
} else if let Some(snapshot) = snapshot_init(imfs, entry, "init.server.lua")? {
|
} else if let Some(snapshot) = snapshot_init(context, imfs, entry, "init.server.lua")? {
|
||||||
// An `init.server.lua` file turns its parent into a Script
|
// An `init.server.lua` file turns its parent into a Script
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
} else if let Some(snapshot) = snapshot_init(imfs, entry, "init.client.lua")? {
|
} else if let Some(snapshot) = snapshot_init(context, imfs, entry, "init.client.lua")? {
|
||||||
// An `init.client.lua` file turns its parent into a LocalScript
|
// An `init.client.lua` file turns its parent into a LocalScript
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
} else {
|
} else {
|
||||||
@@ -114,6 +116,7 @@ fn snapshot_lua_file<F: ImfsFetcher>(
|
|||||||
/// Scripts named `init.lua`, `init.server.lua`, or `init.client.lua` usurp
|
/// Scripts named `init.lua`, `init.server.lua`, or `init.client.lua` usurp
|
||||||
/// their parents, which acts similarly to `__init__.py` from the Python world.
|
/// their parents, which acts similarly to `__init__.py` from the Python world.
|
||||||
fn snapshot_init<F: ImfsFetcher>(
|
fn snapshot_init<F: ImfsFetcher>(
|
||||||
|
context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
folder_entry: &ImfsEntry,
|
folder_entry: &ImfsEntry,
|
||||||
init_name: &str,
|
init_name: &str,
|
||||||
@@ -121,7 +124,7 @@ fn snapshot_init<F: ImfsFetcher>(
|
|||||||
let init_path = folder_entry.path().join(init_name);
|
let init_path = folder_entry.path().join(init_name);
|
||||||
|
|
||||||
if let Some(init_entry) = imfs.get(init_path).with_not_found()? {
|
if let Some(init_entry) = imfs.get(init_path).with_not_found()? {
|
||||||
if let Some(dir_snapshot) = SnapshotDir::from_imfs(imfs, folder_entry)? {
|
if let Some(dir_snapshot) = SnapshotDir::from_imfs(context, imfs, folder_entry)? {
|
||||||
if let Some(mut init_snapshot) = snapshot_lua_file(imfs, &init_entry)? {
|
if let Some(mut init_snapshot) = snapshot_lua_file(imfs, &init_entry)? {
|
||||||
init_snapshot.name = dir_snapshot.name;
|
init_snapshot.name = dir_snapshot.name;
|
||||||
init_snapshot.children = dir_snapshot.children;
|
init_snapshot.children = dir_snapshot.children;
|
||||||
@@ -152,7 +155,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.lua", file);
|
imfs.debug_load_snapshot("/foo.lua", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.lua").unwrap();
|
let entry = imfs.get("/foo.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotLua::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
@@ -165,7 +171,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.server.lua", file);
|
imfs.debug_load_snapshot("/foo.server.lua", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.server.lua").unwrap();
|
let entry = imfs.get("/foo.server.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotLua::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
@@ -178,7 +187,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.client.lua", file);
|
imfs.debug_load_snapshot("/foo.client.lua", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.client.lua").unwrap();
|
let entry = imfs.get("/foo.client.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotLua::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
@@ -199,7 +211,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.meta.json", meta);
|
imfs.debug_load_snapshot("/foo.meta.json", meta);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.lua").unwrap();
|
let entry = imfs.get("/foo.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotLua::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
@@ -220,7 +235,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.meta.json", meta);
|
imfs.debug_load_snapshot("/foo.meta.json", meta);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.server.lua").unwrap();
|
let entry = imfs.get("/foo.server.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotLua::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
@@ -243,7 +261,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/bar.meta.json", meta);
|
imfs.debug_load_snapshot("/bar.meta.json", meta);
|
||||||
|
|
||||||
let entry = imfs.get("/bar.server.lua").unwrap();
|
let entry = imfs.get("/bar.server.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotLua::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
with_settings!({ sort_maps => true }, {
|
with_settings!({ sort_maps => true }, {
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ use crate::{
|
|||||||
snapshot::InstanceSnapshot,
|
snapshot::InstanceSnapshot,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::error::SnapshotError;
|
use super::{context::InstanceSnapshotContext, error::SnapshotError};
|
||||||
|
|
||||||
pub type SnapshotInstanceResult<'a> = Result<Option<InstanceSnapshot<'a>>, SnapshotError>;
|
pub type SnapshotInstanceResult<'a> = Result<Option<InstanceSnapshot<'a>>, SnapshotError>;
|
||||||
pub type SnapshotFileResult = Option<(String, ImfsSnapshot)>;
|
pub type SnapshotFileResult = Option<(String, ImfsSnapshot)>;
|
||||||
|
|
||||||
pub trait SnapshotMiddleware {
|
pub trait SnapshotMiddleware {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static>;
|
) -> SnapshotInstanceResult<'static>;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ pub use self::error::*;
|
|||||||
use rbx_dom_weak::{RbxId, RbxTree};
|
use rbx_dom_weak::{RbxId, RbxTree};
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
csv::SnapshotCsv,
|
csv::SnapshotCsv,
|
||||||
dir::SnapshotDir,
|
dir::SnapshotDir,
|
||||||
json_model::SnapshotJsonModel,
|
json_model::SnapshotJsonModel,
|
||||||
@@ -43,10 +44,12 @@ macro_rules! middlewares {
|
|||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
|
let context = InstanceSnapshotContext::default();
|
||||||
|
|
||||||
$(
|
$(
|
||||||
log::trace!("trying middleware {} on {}", stringify!($middleware), entry.path().display());
|
log::trace!("trying middleware {} on {}", stringify!($middleware), entry.path().display());
|
||||||
|
|
||||||
if let Some(snapshot) = $middleware::from_imfs(imfs, entry)? {
|
if let Some(snapshot) = $middleware::from_imfs(&context, imfs, entry)? {
|
||||||
log::trace!("middleware {} success on {}", stringify!($middleware), entry.path().display());
|
log::trace!("middleware {} success on {}", stringify!($middleware), entry.path().display());
|
||||||
return Ok(Some(snapshot));
|
return Ok(Some(snapshot));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
error::SnapshotError,
|
error::SnapshotError,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
snapshot_from_imfs,
|
snapshot_from_imfs,
|
||||||
@@ -21,6 +22,7 @@ pub struct SnapshotProject;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotProject {
|
impl SnapshotMiddleware for SnapshotProject {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -31,7 +33,7 @@ impl SnapshotMiddleware for SnapshotProject {
|
|||||||
// TODO: Do we need to muck with the relevant paths if we're a
|
// TODO: Do we need to muck with the relevant paths if we're a
|
||||||
// project file within a folder? Should the folder path be the
|
// project file within a folder? Should the folder path be the
|
||||||
// relevant path instead of the project file path?
|
// relevant path instead of the project file path?
|
||||||
Some(entry) => return SnapshotProject::from_imfs(imfs, &entry),
|
Some(entry) => return SnapshotProject::from_imfs(context, imfs, &entry),
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,7 +211,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -235,7 +238,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo/hello.project.json").unwrap();
|
let entry = imfs.get("/foo/hello.project.json").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -267,7 +271,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -296,7 +301,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -326,7 +332,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -353,7 +360,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -387,7 +395,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -425,7 +434,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -468,7 +478,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo", dir);
|
imfs.debug_load_snapshot("/foo", dir);
|
||||||
|
|
||||||
let entry = imfs.get("/foo").unwrap();
|
let entry = imfs.get("/foo").unwrap();
|
||||||
let instance_snapshot = SnapshotProject::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotProject::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -14,6 +15,7 @@ pub struct SnapshotRbxlx;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxlx {
|
impl SnapshotMiddleware for SnapshotRbxlx {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
_context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -16,6 +17,7 @@ pub struct SnapshotRbxm;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxm {
|
impl SnapshotMiddleware for SnapshotRbxm {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
_context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -68,7 +70,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.rbxm", file);
|
imfs.debug_load_snapshot("/foo.rbxm", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.rbxm").unwrap();
|
let entry = imfs.get("/foo.rbxm").unwrap();
|
||||||
let instance_snapshot = SnapshotRbxm::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotRbxm::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(instance_snapshot.name, "foo");
|
assert_eq!(instance_snapshot.name, "foo");
|
||||||
assert_eq!(instance_snapshot.class_name, "Folder");
|
assert_eq!(instance_snapshot.class_name, "Folder");
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -14,6 +15,7 @@ pub struct SnapshotRbxmx;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxmx {
|
impl SnapshotMiddleware for SnapshotRbxmx {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
_context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -74,7 +76,8 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.rbxmx", file);
|
imfs.debug_load_snapshot("/foo.rbxmx", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.rbxmx").unwrap();
|
let entry = imfs.get("/foo.rbxmx").unwrap();
|
||||||
let instance_snapshot = SnapshotRbxmx::from_imfs(&mut imfs, &entry)
|
let instance_snapshot =
|
||||||
|
SnapshotRbxmx::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
context::InstanceSnapshotContext,
|
||||||
error::SnapshotError,
|
error::SnapshotError,
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
@@ -19,6 +20,7 @@ pub struct SnapshotTxt;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotTxt {
|
impl SnapshotMiddleware for SnapshotTxt {
|
||||||
fn from_imfs<F: ImfsFetcher>(
|
fn from_imfs<F: ImfsFetcher>(
|
||||||
|
_context: &InstanceSnapshotContext,
|
||||||
imfs: &mut Imfs<F>,
|
imfs: &mut Imfs<F>,
|
||||||
entry: &ImfsEntry,
|
entry: &ImfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult<'static> {
|
||||||
@@ -114,7 +116,10 @@ mod test {
|
|||||||
imfs.debug_load_snapshot("/foo.txt", file);
|
imfs.debug_load_snapshot("/foo.txt", file);
|
||||||
|
|
||||||
let entry = imfs.get("/foo.txt").unwrap();
|
let entry = imfs.get("/foo.txt").unwrap();
|
||||||
let instance_snapshot = SnapshotTxt::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot =
|
||||||
|
SnapshotTxt::from_imfs(&InstanceSnapshotContext::default(), &mut imfs, &entry)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_yaml_snapshot!(instance_snapshot);
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user