mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 05:35:10 +00:00
Remove lifetime from SnapshotInstanceResult
This commit is contained in:
@@ -23,7 +23,7 @@ impl SnapshotMiddleware for SnapshotCsv {
|
|||||||
_context: &mut InstanceSnapshotContext,
|
_context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_directory() {
|
if entry.is_directory() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl SnapshotMiddleware for SnapshotDir {
|
|||||||
context: &mut InstanceSnapshotContext,
|
context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_file() {
|
if entry.is_file() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl SnapshotMiddleware for SnapshotJsonModel {
|
|||||||
_context: &mut InstanceSnapshotContext,
|
_context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_directory() {
|
if entry.is_directory() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl SnapshotMiddleware for SnapshotLua {
|
|||||||
context: &mut InstanceSnapshotContext,
|
context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
let file_name = entry.path().file_name().unwrap().to_string_lossy();
|
let file_name = entry.path().file_name().unwrap().to_string_lossy();
|
||||||
|
|
||||||
// These paths alter their parent instance, so we don't need to turn
|
// These paths alter their parent instance, so we don't need to turn
|
||||||
@@ -55,10 +55,7 @@ impl SnapshotMiddleware for SnapshotLua {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Core routine for turning Lua files into snapshots.
|
/// Core routine for turning Lua files into snapshots.
|
||||||
fn snapshot_lua_file<F: VfsFetcher>(
|
fn snapshot_lua_file<F: VfsFetcher>(vfs: &Vfs<F>, entry: &VfsEntry) -> SnapshotInstanceResult {
|
||||||
vfs: &Vfs<F>,
|
|
||||||
entry: &VfsEntry,
|
|
||||||
) -> SnapshotInstanceResult<'static> {
|
|
||||||
let file_name = entry.path().file_name().unwrap().to_string_lossy();
|
let file_name = entry.path().file_name().unwrap().to_string_lossy();
|
||||||
|
|
||||||
let (class_name, instance_name) = if let Some(name) = match_trailing(&file_name, ".server.lua")
|
let (class_name, instance_name) = if let Some(name) = match_trailing(&file_name, ".server.lua")
|
||||||
@@ -122,7 +119,7 @@ fn snapshot_init<F: VfsFetcher>(
|
|||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
folder_entry: &VfsEntry,
|
folder_entry: &VfsEntry,
|
||||||
init_name: &str,
|
init_name: &str,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
let init_path = folder_entry.path().join(init_name);
|
let init_path = folder_entry.path().join(init_name);
|
||||||
|
|
||||||
if let Some(init_entry) = vfs.get(init_path).with_not_found()? {
|
if let Some(init_entry) = vfs.get(init_path).with_not_found()? {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{context::InstanceSnapshotContext, error::SnapshotError};
|
use super::{context::InstanceSnapshotContext, error::SnapshotError};
|
||||||
|
|
||||||
pub type SnapshotInstanceResult<'a> = Result<Option<InstanceSnapshot>, SnapshotError>;
|
pub type SnapshotInstanceResult = Result<Option<InstanceSnapshot>, SnapshotError>;
|
||||||
pub type SnapshotFileResult = Option<(String, VfsSnapshot)>;
|
pub type SnapshotFileResult = Option<(String, VfsSnapshot)>;
|
||||||
|
|
||||||
pub trait SnapshotMiddleware {
|
pub trait SnapshotMiddleware {
|
||||||
@@ -15,7 +15,7 @@ pub trait SnapshotMiddleware {
|
|||||||
context: &mut InstanceSnapshotContext,
|
context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static>;
|
) -> SnapshotInstanceResult;
|
||||||
|
|
||||||
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
fn from_instance(_tree: &RbxTree, _id: RbxId) -> SnapshotFileResult {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ macro_rules! middlewares {
|
|||||||
context: &mut InstanceSnapshotContext,
|
context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
$(
|
$(
|
||||||
log::trace!("trying middleware {} on {}", stringify!($middleware), entry.path().display());
|
log::trace!("trying middleware {} on {}", stringify!($middleware), entry.path().display());
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl SnapshotMiddleware for SnapshotProject {
|
|||||||
context: &mut InstanceSnapshotContext,
|
context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_directory() {
|
if entry.is_directory() {
|
||||||
let project_path = entry.path().join("default.project.json");
|
let project_path = entry.path().join("default.project.json");
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ pub fn snapshot_project_node<F: VfsFetcher>(
|
|||||||
instance_name: &str,
|
instance_name: &str,
|
||||||
node: &ProjectNode,
|
node: &ProjectNode,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
let name = Cow::Owned(instance_name.to_owned());
|
let name = Cow::Owned(instance_name.to_owned());
|
||||||
let mut class_name = node
|
let mut class_name = node
|
||||||
.class_name
|
.class_name
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ impl SnapshotMiddleware for SnapshotRbxlx {
|
|||||||
_context: &mut InstanceSnapshotContext,
|
_context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_directory() {
|
if entry.is_directory() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ impl SnapshotMiddleware for SnapshotRbxm {
|
|||||||
_context: &mut InstanceSnapshotContext,
|
_context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_directory() {
|
if entry.is_directory() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ impl SnapshotMiddleware for SnapshotRbxmx {
|
|||||||
_context: &mut InstanceSnapshotContext,
|
_context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_directory() {
|
if entry.is_directory() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl SnapshotMiddleware for SnapshotTxt {
|
|||||||
_context: &mut InstanceSnapshotContext,
|
_context: &mut InstanceSnapshotContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
if entry.is_directory() {
|
if entry.is_directory() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ impl SnapshotMiddleware for SnapshotUserPlugins {
|
|||||||
context: &mut InstanceSnapshotContext,
|
context: &mut InstanceSnapshotContext,
|
||||||
_vfs: &Vfs<F>,
|
_vfs: &Vfs<F>,
|
||||||
_entry: &VfsEntry,
|
_entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult<'static> {
|
) -> SnapshotInstanceResult {
|
||||||
// User plugins are only enabled if present on the snapshot context.
|
// User plugins are only enabled if present on the snapshot context.
|
||||||
let plugin_context = match &mut context.plugin_context {
|
let plugin_context = match &mut context.plugin_context {
|
||||||
Some(ctx) => ctx,
|
Some(ctx) => ctx,
|
||||||
|
|||||||
Reference in New Issue
Block a user