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

Function load_identity_by_id

atomic-agent/src/identity.rs:286–307  ·  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

284
285/// Load identity info from a directory matching the given ID.
286fn load_identity_by_id(identities_dir: &Path, id_base32: &str) -> Option<UserIdentityInfo> {
287 // The ID might be used directly as part of the directory name
288 let entries = std::fs::read_dir(identities_dir).ok()?;
289
290 for entry in entries.flatten() {
291 let _dir_name = entry.file_name().to_string_lossy().to_string();
292
293 // Skip non-directories and config files
294 if !entry.path().is_dir() {
295 continue;
296 }
297
298 // Check if this directory's identity.toml contains the matching ID
299 let identity_path = entry.path().join("identity.toml");
300 if let Ok(content) = std::fs::read_to_string(&identity_path) {
301 if content.contains(id_base32) {
302 return parse_identity_toml(&content);
303 }
304 }
305 }
306 None
307}
308
309/// Scan all identity directories and try to find one matching the ID.
310fn 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