use host_identity::sources::{AppSpecific, MachineIdFile};
use host_identity::{Error, HostId, Resolver};
const APP_ID: &str = "com.example.telemetry";
const OTHER_APP_ID: &str = "com.example.crash-reporter";
fn main() -> Result<(), Error> {
let id = resolve_for(APP_ID)?;
println!("app_id = {APP_ID}");
println!("uuid = {id}");
println!("source = {}", id.source());
let again = resolve_for(APP_ID)?;
assert_eq!(id, again);
println!("stable = deterministic (re-resolved with same app_id)");
let other = resolve_for(OTHER_APP_ID)?;
assert_ne!(id, other);
println!("app_id = {OTHER_APP_ID}");
println!("uuid = {other}");
Ok(())
}
fn resolve_for(app_id: &str) -> Result<HostId, Error> {
Resolver::new()
.push(AppSpecific::new(MachineIdFile::new(), app_id.as_bytes()))
.resolve()
}