Skip to main content

relabel

Function relabel 

Source
pub fn relabel(path: &Path, label: &str) -> Result<NodeIdentity, MeshError>
Expand description

Give the identity at path a display label, keeping its key: the node id, and every signature it ever made, are unchanged. The label is presentation — what a person reads as macbook-pro in a list of devices — and is refused unless it is a short name of letters, digits, ., _ and -, because it is printed wherever this node is named.

use majordomus_cli::mesh::identity::{relabel, NodeIdentity};
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("node.json");
let before = NodeIdentity::load_or_create(&path).unwrap();
let after = relabel(&path, "mac-mini").unwrap();
assert_eq!(after.public.display_name, "mac-mini");
assert_eq!(after.public.node_id, before.public.node_id, "the key is the identity");
assert!(relabel(&path, "two words").is_err());