mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-21 20:21:38 +00:00
parent
6de74b41b3
commit
1cbe272e19
6 changed files with 25 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{borrow::Cow, collections::HashMap};
|
||||
use std::{borrow::Cow, collections::HashMap, path::Path};
|
||||
|
||||
use rbx_dom_weak::UnresolvedRbxValue;
|
||||
use rbx_reflection::try_resolve_value;
|
||||
|
|
@ -6,6 +6,8 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use crate::snapshot::InstanceSnapshot;
|
||||
|
||||
use super::error::SnapshotError;
|
||||
|
||||
/// Represents metadata in a sibling file with the same basename.
|
||||
///
|
||||
/// As an example, hello.meta.json next to hello.lua would allow assigning
|
||||
|
|
@ -21,10 +23,9 @@ pub struct AdjacentMetadata {
|
|||
}
|
||||
|
||||
impl AdjacentMetadata {
|
||||
pub fn from_slice(slice: &[u8]) -> Self {
|
||||
pub fn from_slice(slice: &[u8], path: &Path) -> Result<Self, SnapshotError> {
|
||||
serde_json::from_slice(slice)
|
||||
// TODO: Turn into error type
|
||||
.expect(".meta.json file was malformed")
|
||||
.map_err(|source| SnapshotError::malformed_meta_json(source, path))
|
||||
}
|
||||
|
||||
pub fn apply_ignore_unknown_instances(&mut self, snapshot: &mut InstanceSnapshot) {
|
||||
|
|
@ -74,10 +75,9 @@ pub struct DirectoryMetadata {
|
|||
}
|
||||
|
||||
impl DirectoryMetadata {
|
||||
pub fn from_slice(slice: &[u8]) -> Self {
|
||||
pub fn from_slice(slice: &[u8], path: &Path) -> Result<Self, SnapshotError> {
|
||||
serde_json::from_slice(slice)
|
||||
// TODO: Turn into error type
|
||||
.expect("init.meta.json file was malformed")
|
||||
.map_err(|source| SnapshotError::malformed_meta_json(source, path))
|
||||
}
|
||||
|
||||
pub fn apply_all(&mut self, snapshot: &mut InstanceSnapshot) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue