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

Method load_by_name

atomic-identity/src/store.rs:518–540  ·  view source on GitHub ↗

Load an identity by name.

(&self, name: &str)

Source from the content-addressed store, hash-verified

516
517 /// Load an identity by name.
518 pub fn load_by_name(&self, name: &str) -> Result<Identity, IdentityError> {
519 // Try to find an identity directory with a matching name
520 for entry in fs::read_dir(&self.root)? {
521 let entry = entry?;
522 let path = entry.path();
523
524 if path.is_dir() {
525 let identity_path = path.join(Self::IDENTITY_FILE);
526 if identity_path.exists() {
527 let content = fs::read_to_string(&identity_path)?;
528 let stored: StoredIdentity = toml::from_str(&content)?;
529
530 if stored.name == name {
531 return stored.to_identity();
532 }
533 }
534 }
535 }
536
537 Err(IdentityError::NotFound {
538 name: name.to_string(),
539 })
540 }
541
542 /// Load the secret key for an identity.
543 pub fn load_secret_key(

Callers 11

attach_identityFunction · 0.80
check_push_credentialsFunction · 0.80
build_client_with_orgFunction · 0.80
resolve_authorMethod · 0.80
runMethod · 0.80
runMethod · 0.80
executeMethod · 0.80
runMethod · 0.80
runMethod · 0.80
exists_by_nameMethod · 0.80
test_store_load_by_nameFunction · 0.80

Calls 4

is_dirMethod · 0.80
to_identityMethod · 0.80
pathMethod · 0.45
existsMethod · 0.45

Tested by 1

test_store_load_by_nameFunction · 0.64