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

Method build

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

Build the identity, generating a keypair if needed.

(self)

Source from the content-addressed store, hash-verified

467
468 /// Build the identity, generating a keypair if needed.
469 pub fn build(self) -> Result<Identity, IdentityError> {
470 let public_key = match (self.keypair, self.public_key) {
471 (Some(kp), _) => kp.public,
472 (None, Some(pk)) => pk,
473 (None, None) => KeyPair::generate().public,
474 };
475
476 let id = IdentityId::from_public_key(&public_key);
477
478 let mut metadata = IdentityMetadata::new();
479 if let Some(desc) = self.description {
480 metadata.description = Some(desc);
481 }
482 if let Some(exp) = self.expires_at {
483 metadata.expires_at = Some(exp);
484 }
485
486 Ok(Identity {
487 id,
488 name: self.name,
489 email: self.email,
490 public_key,
491 identity_type: self.identity_type,
492 usage: self.usage,
493 metadata,
494 delegated_by: self.delegated_by,
495 })
496 }
497}
498
499/// Author information compatible with atomic-core's change headers.

Callers 14

test_identity_builderFunction · 0.45
test_agent_identityFunction · 0.45
test_delegated_identityFunction · 0.45
test_identity_to_authorFunction · 0.45
test_delegationFunction · 0.45
test_identity_to_authorFunction · 0.45

Calls

no outgoing calls

Tested by 14

test_identity_builderFunction · 0.36
test_agent_identityFunction · 0.36
test_delegated_identityFunction · 0.36
test_identity_to_authorFunction · 0.36
test_delegationFunction · 0.36
test_identity_to_authorFunction · 0.36