Introduce InstanceContext (#270)

* Add instance context with dummy field

* Remove stub field
This commit is contained in:
Lucien Greathouse
2019-12-03 15:30:20 -08:00
committed by GitHub
parent a48c238ed7
commit 12df80da56
38 changed files with 81 additions and 9 deletions

View File

@@ -43,6 +43,14 @@ pub struct InstanceMetadata {
// TODO: Change this to be a SmallVec for performance in common cases?
#[serde(serialize_with = "path_serializer::serialize_vec_absolute")]
pub relevant_paths: Vec<PathBuf>,
/// Contains information about this instance that should persist between
/// snapshot invocations and is generally inherited.
///
/// If an instance has a piece of context attached to it, then the next time
/// that instance's instigating source is snapshotted directly, the same
/// context will be passed into it.
pub context: InstanceContext,
}
impl InstanceMetadata {
@@ -51,6 +59,7 @@ impl InstanceMetadata {
ignore_unknown_instances: false,
instigating_source: None,
relevant_paths: Vec::new(),
context: InstanceContext::default(),
}
}
@@ -74,6 +83,13 @@ impl InstanceMetadata {
..self
}
}
pub fn context(self, context: &InstanceContext) -> Self {
Self {
context: context.clone(),
..self
}
}
}
impl Default for InstanceMetadata {
@@ -82,6 +98,15 @@ impl Default for InstanceMetadata {
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InstanceContext {}
impl Default for InstanceContext {
fn default() -> Self {
InstanceContext {}
}
}
#[derive(Clone, PartialEq, Serialize, Deserialize)]
pub enum InstigatingSource {
Path(#[serde(serialize_with = "path_serializer::serialize_absolute")] PathBuf),

View File

@@ -1,6 +1,6 @@
---
source: src/snapshot/tests/apply.rs
expression: tree_value
expression: tree_view
---
id: id-1
name: ROOT
@@ -12,4 +12,5 @@ properties:
metadata:
ignore_unknown_instances: false
relevant_paths: []
children: []
context: {}
children: []

View File

@@ -1,6 +1,6 @@
---
source: src/snapshot/tests/apply.rs
expression: tree_value
expression: tree_view
---
id: id-1
name: ROOT
@@ -9,4 +9,5 @@ properties: {}
metadata:
ignore_unknown_instances: false
relevant_paths: []
children: []
context: {}
children: []

View File

@@ -1,6 +1,6 @@
---
source: src/snapshot/tests/apply.rs
expression: tree_value
expression: tree_view
---
id: id-1
name: ROOT
@@ -12,4 +12,5 @@ properties:
metadata:
ignore_unknown_instances: false
relevant_paths: []
children: []
context: {}
children: []

View File

@@ -1,6 +1,6 @@
---
source: src/snapshot/tests/apply.rs
expression: tree_value
expression: tree_view
---
id: id-1
name: "Hello, world!"
@@ -9,4 +9,5 @@ properties: {}
metadata:
ignore_unknown_instances: false
relevant_paths: []
children: []
context: {}
children: []

View File

@@ -10,8 +10,9 @@ added_instances:
metadata:
ignore_unknown_instances: false
relevant_paths: []
context: {}
name: New
class_name: Folder
properties: {}
children: []
updated_instances: []
updated_instances: []