forked from rojo-rbx/rojo
VFS in external crate (#297)
* vroom * Port dir middleware * Filter rules * Directory metadata * Project support * Enable Lua support * StringValue support * CSV * rbxm, rbxmx, and rbxlx * JSON models * Clean up some warnings * Strip out PathMap * Unwatch paths when they're reported as removed * Fix 'rojo upload' behavior * Upgrade to Insta 0.13.1 * Update dependencies * Release 0.6.0-alpha.2 * Fix bad merge * Replace MemoryBackend with InMemoryFs * Sledgehammer tests into passing for now * Txt middleware * Update easy snapshot tests * Lua tests * Project middleware tests * Try to fix test failures by sorting * Port first set of serve session tests * Add InMemoryFs::raise_event * Finish porting serve session tests * Remove UI code for introspecting VFS for now * VFS docs
This commit is contained in:
committed by
GitHub
parent
a884f693ae
commit
477e0ada32
@@ -15,46 +15,37 @@ mod rbxlx;
|
||||
mod rbxm;
|
||||
mod rbxmx;
|
||||
mod txt;
|
||||
mod user_plugins;
|
||||
mod util;
|
||||
|
||||
pub use self::error::*;
|
||||
|
||||
use rbx_dom_weak::{RbxId, RbxTree};
|
||||
use std::path::Path;
|
||||
|
||||
use vfs::Vfs;
|
||||
|
||||
use self::middleware::{SnapshotInstanceResult, SnapshotMiddleware};
|
||||
use self::{
|
||||
csv::SnapshotCsv,
|
||||
dir::SnapshotDir,
|
||||
json_model::SnapshotJsonModel,
|
||||
lua::SnapshotLua,
|
||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
||||
project::SnapshotProject,
|
||||
rbxlx::SnapshotRbxlx,
|
||||
rbxm::SnapshotRbxm,
|
||||
rbxmx::SnapshotRbxmx,
|
||||
csv::SnapshotCsv, dir::SnapshotDir, json_model::SnapshotJsonModel, lua::SnapshotLua,
|
||||
project::SnapshotProject, rbxlx::SnapshotRbxlx, rbxm::SnapshotRbxm, rbxmx::SnapshotRbxmx,
|
||||
txt::SnapshotTxt,
|
||||
user_plugins::SnapshotUserPlugins,
|
||||
};
|
||||
use crate::{
|
||||
snapshot::InstanceContext,
|
||||
vfs::{Vfs, VfsEntry, VfsFetcher},
|
||||
};
|
||||
use crate::snapshot::InstanceContext;
|
||||
|
||||
pub use self::project::snapshot_project_node;
|
||||
|
||||
macro_rules! middlewares {
|
||||
( $($middleware: ident,)* ) => {
|
||||
/// Generates a snapshot of instances from the given VfsEntry.
|
||||
pub fn snapshot_from_vfs<F: VfsFetcher>(
|
||||
/// Generates a snapshot of instances from the given path.
|
||||
pub fn snapshot_from_vfs(
|
||||
context: &InstanceContext,
|
||||
vfs: &Vfs<F>,
|
||||
entry: &VfsEntry,
|
||||
vfs: &Vfs,
|
||||
path: &Path,
|
||||
) -> SnapshotInstanceResult {
|
||||
$(
|
||||
log::trace!("trying middleware {} on {}", stringify!($middleware), entry.path().display());
|
||||
log::trace!("trying middleware {} on {}", stringify!($middleware), path.display());
|
||||
|
||||
if let Some(snapshot) = $middleware::from_vfs(context, vfs, entry)? {
|
||||
log::trace!("middleware {} success on {}", stringify!($middleware), entry.path().display());
|
||||
if let Some(snapshot) = $middleware::from_vfs(context, vfs, path)? {
|
||||
log::trace!("middleware {} success on {}", stringify!($middleware), path.display());
|
||||
return Ok(Some(snapshot));
|
||||
}
|
||||
)*
|
||||
@@ -62,24 +53,11 @@ macro_rules! middlewares {
|
||||
log::trace!("no middleware returned Ok(Some)");
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Generates an in-memory filesystem snapshot of the given Roblox
|
||||
/// instance.
|
||||
pub fn snapshot_from_instance(tree: &RbxTree, id: RbxId) -> SnapshotFileResult {
|
||||
$(
|
||||
if let Some(result) = $middleware::from_instance(tree, id) {
|
||||
return Some(result);
|
||||
}
|
||||
)*
|
||||
|
||||
None
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
middlewares! {
|
||||
SnapshotProject,
|
||||
SnapshotUserPlugins,
|
||||
SnapshotJsonModel,
|
||||
SnapshotRbxlx,
|
||||
SnapshotRbxmx,
|
||||
|
||||
Reference in New Issue
Block a user