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

Function parse_identity_toml

atomic-agent/src/identity.rs:517–542  ·  view source on GitHub ↗

Parse minimal identity info from an identity.toml file.

(content: &str)

Source from the content-addressed store, hash-verified

515
516/// Parse minimal identity info from an identity.toml file.
517fn parse_identity_toml(content: &str) -> Option<UserIdentityInfo> {
518 let mut name = None;
519 let mut email = None;
520 let mut public_key = None;
521
522 for line in content.lines() {
523 let trimmed = line.trim();
524
525 if trimmed.starts_with("name") && name.is_none() {
526 name = extract_toml_string_value(trimmed);
527 } else if trimmed.starts_with("email") && email.is_none() {
528 email = extract_toml_string_value(trimmed);
529 } else if trimmed.starts_with("public_key") && public_key.is_none() {
530 public_key = extract_toml_string_value(trimmed);
531 }
532 }
533
534 let name = name?;
535 let public_key = public_key.unwrap_or_else(|| "unknown".to_string());
536
537 Some(UserIdentityInfo {
538 name,
539 email,
540 public_key_base32: public_key,
541 })
542}
543
544/// Extract a string value from a TOML `key = "value"` line.
545fn extract_toml_string_value(line: &str) -> Option<String> {

Callers 2

load_identity_by_idFunction · 0.85

Calls 3

is_noneMethod · 0.80
linesMethod · 0.45

Tested by

no test coverage detected