Use the identities stored in the configuration directory to convert public keys to names and email addresses.
D467LQZ62MTKWYPTMRBYTTR63CZDCE5WGBIGLQMSWAQYPHC3XITAC
let mut identities: HashMap<String, String> = HashMap::new();
Self::load_identities(&mut identities, &repo_path.join(".pijul/identities")).unwrap_or(());
match env::var("HOME") {
Ok(home) => {
Self::load_identities(
&mut identities,
&Path::new(&home).join(".config/pijul/identities"),
)
.unwrap_or(());
}
Err(..) => {}
}
fn load_identities(
identities: &mut HashMap<String, String>,
dir: &Path,
) -> Result<(), Box<dyn Error>> {
let files = fs::read_dir(dir)?;
for file in files {
match fs::read_to_string(dir.join(file?.path()).join("identity.toml")) {
Ok(content) => {
let id: Identity = toml::from_str(&content)?;
identities.insert(
id.public_key.key,
format!("{} <{}>", id.display_name, id.email),
);
}
Err(..) => {}
}
}
return Ok(());
}
serde = "1.0.156"
toml = "0.5.11"