pub struct Deduplicated {
pub kept: String,
pub dropped: Vec<String>,
pub key: String,
pub detail: String,
pub paths: usize,
}Expand description
Two names, one thing. The compiler keeps one entry and records the collapse here, so that “why is this ADR listed once when four things point at it” has an answer that is state rather than a log line.
One type covers two different collapses, and dropped is how a reader tells them apart.
Structural collapse is the same identifier reached several ways: nothing was
discarded, so dropped is empty and paths is the count that makes the row worth
printing — this is the record that four things pointing at one ADR produced one entry.
Semantic collapse is two different identifiers standing for one thing, one file
indexed under two kinds or one rule at two versions: there dropped names what lost,
because something really was discarded and a reader is entitled to know what.
use majordomus_cli::devcontext::Deduplicated;
use serde_json::json;
// structural: one identifier, four ways in, nothing discarded
let structural: Deduplicated = serde_json::from_value(json!({
"kept": "majordomus://adr/0052",
"dropped": [],
"key": "uri",
"detail": "one object reached by 4 discovery path(s)",
"paths": 4,
})).unwrap();
assert!(structural.dropped.is_empty(), "nothing lost; this is a record, not a decision");
assert!(structural.paths > 1, "which is what makes the row worth printing");
assert_eq!(structural.key, "uri");
// semantic: two identifiers for one rule, and the older version lost
let semantic: Deduplicated = serde_json::from_value(json!({
"kept": "majordomus://rule/project.x@2",
"dropped": ["majordomus://rule/project.x@1"],
"key": "identity",
"detail": "one rule at two versions; the newer is in the answer",
"paths": 1,
})).unwrap();
assert_eq!(semantic.dropped, ["majordomus://rule/project.x@1"]);
assert_ne!(semantic.kept, semantic.dropped[0], "two names, and one of them lost");Fields§
§kept: StringThe entry that survived.
dropped: Vec<String>What was folded into it, or dropped for it.
key: StringWhat made them the same thing: uri, path or identity.
detail: StringThe same, in words.
paths: usizeHow many discovery paths reached the surviving entry.
Trait Implementations§
Source§impl Clone for Deduplicated
impl Clone for Deduplicated
Source§fn clone(&self) -> Deduplicated
fn clone(&self) -> Deduplicated
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Deduplicated
impl Debug for Deduplicated
Source§impl<'de> Deserialize<'de> for Deduplicated
impl<'de> Deserialize<'de> for Deduplicated
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Deduplicated
impl JsonSchema for Deduplicated
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ordered for Deduplicated
Filed under what made the two the same thing, then by the entry that survived — which
is unique, because one entry is kept once under one key.
impl Ordered for Deduplicated
Filed under what made the two the same thing, then by the entry that survived — which is unique, because one entry is kept once under one key.
Source§impl PartialEq for Deduplicated
impl PartialEq for Deduplicated
Source§fn eq(&self, other: &Deduplicated) -> bool
fn eq(&self, other: &Deduplicated) -> bool
self and other values to be equal, and is used by ==.