mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Metadata per instance is a go
This commit is contained in:
parent
f2dc1d8898
commit
3f526cd127
4 changed files with 65 additions and 48 deletions
|
|
@ -20,8 +20,23 @@ use crate::{
|
|||
project::InstanceProjectNodeMetadata,
|
||||
snapshot_reconciler::InstanceChanges,
|
||||
visualize::{VisualizeRbxSession, VisualizeImfs, graphviz_to_svg},
|
||||
rbx_session::{MetadataPerInstance},
|
||||
};
|
||||
|
||||
/// Contains the instance metadata relevant to Rojo clients.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct InstanceMetadata {
|
||||
ignore_unknown_instances: bool,
|
||||
}
|
||||
|
||||
impl InstanceMetadata {
|
||||
fn from_session_metadata(meta: &MetadataPerInstance) -> InstanceMetadata {
|
||||
InstanceMetadata {
|
||||
ignore_unknown_instances: meta.ignore_unknown_instances,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Used to attach metadata specific to Rojo to instances, which come from the
|
||||
/// rbx_tree crate.
|
||||
///
|
||||
|
|
@ -33,7 +48,7 @@ pub struct InstanceWithMetadata<'a> {
|
|||
pub instance: Cow<'a, RbxInstance>,
|
||||
|
||||
#[serde(rename = "Metadata")]
|
||||
pub metadata: Option<Cow<'a, InstanceProjectNodeMetadata>>,
|
||||
pub metadata: Option<InstanceMetadata>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
@ -163,7 +178,7 @@ impl Server {
|
|||
for &requested_id in &requested_ids {
|
||||
if let Some(instance) = tree.get_instance(requested_id) {
|
||||
let metadata = rbx_session.get_instance_metadata(requested_id)
|
||||
.map(Cow::Borrowed);
|
||||
.map(InstanceMetadata::from_session_metadata);
|
||||
|
||||
instances.insert(instance.get_id(), InstanceWithMetadata {
|
||||
instance: Cow::Borrowed(instance),
|
||||
|
|
@ -172,7 +187,7 @@ impl Server {
|
|||
|
||||
for descendant in tree.descendants(requested_id) {
|
||||
let descendant_meta = rbx_session.get_instance_metadata(descendant.get_id())
|
||||
.map(Cow::Borrowed);
|
||||
.map(InstanceMetadata::from_session_metadata);
|
||||
|
||||
instances.insert(descendant.get_id(), InstanceWithMetadata {
|
||||
instance: Cow::Borrowed(descendant),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue