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

Method build

atomic-identity/src/identity.rs:501–528  ·  view source on GitHub ↗

Build the identity, generating a keypair if needed.

(self)

Source from the content-addressed store, hash-verified

499
500 /// Build the identity, generating a keypair if needed.
501 pub fn build(self) -> Result<Identity, IdentityError> {
502 let public_key = match (self.keypair, self.public_key) {
503 (Some(kp), _) => kp.public,
504 (None, Some(pk)) => pk,
505 (None, None) => KeyPair::generate().public,
506 };
507
508 let id = IdentityId::from_public_key(&public_key);
509
510 let mut metadata = IdentityMetadata::new();
511 if let Some(desc) = self.description {
512 metadata.description = Some(desc);
513 }
514 if let Some(exp) = self.expires_at {
515 metadata.expires_at = Some(exp);
516 }
517
518 Ok(Identity {
519 id,
520 name: self.name,
521 email: self.email,
522 public_key,
523 identity_type: self.identity_type,
524 usage: self.usage,
525 metadata,
526 delegated_by: self.delegated_by,
527 })
528 }
529}
530
531/// 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