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

Method load_by_name

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

Load an identity by name.

(&self, name: &str)

Source from the content-addressed store, hash-verified

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

Callers 15

load_identity_lenientFunction · 0.80
resolve_authorMethod · 0.80
runMethod · 0.80
executeMethod · 0.80
resolve_verifierFunction · 0.80
resolve_personFunction · 0.80
runMethod · 0.80
runMethod · 0.80
resolve_verifierFunction · 0.80
runMethod · 0.80
load_identity_or_defaultFunction · 0.80

Calls 4

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

Tested by 3

runMethod · 0.64
runMethod · 0.64
test_store_load_by_nameFunction · 0.64