MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / load_identity_by_id

Function load_identity_by_id

atomic-agent/src/identity.rs:469–490  ·  view source on GitHub ↗

Load identity info from a directory matching the given ID.

(identities_dir: &Path, id_base32: &str)

Source from the content-addressed store, hash-verified

467
468/// Load identity info from a directory matching the given ID.
469fn load_identity_by_id(identities_dir: &Path, id_base32: &str) -> Option<UserIdentityInfo> {
470 // The ID might be used directly as part of the directory name
471 let entries = std::fs::read_dir(identities_dir).ok()?;
472
473 for entry in entries.flatten() {
474 let _dir_name = entry.file_name().to_string_lossy().to_string();
475
476 // Skip non-directories and config files
477 if !entry.path().is_dir() {
478 continue;
479 }
480
481 // Check if this directory's identity.toml contains the matching ID
482 let identity_path = entry.path().join("identity.toml");
483 if let Ok(content) = std::fs::read_to_string(&identity_path) {
484 if content.contains(id_base32) {
485 return parse_identity_toml(&content);
486 }
487 }
488 }
489 None
490}
491
492/// Scan all identity directories and try to find one matching the ID.
493fn load_identity_by_scanning(identities_dir: &Path, id_base32: &str) -> Option<UserIdentityInfo> {

Callers 1

Calls 5

parse_identity_tomlFunction · 0.85
file_nameMethod · 0.80
is_dirMethod · 0.80
pathMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected