Skip to main content

redact

Function redact 

Source
pub fn redact(scenes: &BTreeMap<String, Value>) -> BTreeMap<String, Value>
Expand description

The scenes of a projection made fit for publication: identities replaced by ordinals, event bodies and names never carried. A scene this does not know is dropped.

use majordomus_cli::capability::builtin::observatory::redact;
use serde_json::json;
let scenes = [("mesh".to_string(), json!({
    "machines": [{ "id": "641bdb94dae9f622", "label": "641bdb94", "local": true,
                   "runtimes": [{ "id": "b10f19aa2cd888a6", "liveness": "live", "this": true, "sessions": 2 }] }],
    "known": 1, "refused": 0,
}))].into_iter().collect();
let out = redact(&scenes);
let text = serde_json::to_string(&out).unwrap();
assert!(!text.contains("641bdb94") && !text.contains("b10f19aa"));
assert_eq!(out["mesh"]["machines"][0]["label"], "machine 1");
assert_eq!(out["mesh"]["machines"][0]["runtimes"][0]["liveness"], "live");