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

Function record_from_document

libatomic/src/identity_transport.rs:65–80  ·  view source on GitHub ↗

Build a transport record from a fetched identity document: recompute the canonical hash, mark it `Adopted` (it was never minted locally).

(document: &serde_json::Value)

Source from the content-addressed store, hash-verified

63/// Build a transport record from a fetched identity document: recompute the
64/// canonical hash, mark it `Adopted` (it was never minted locally).
65fn record_from_document(document: &serde_json::Value) -> Result<ProjectIdentityRecord, String> {
66 let object = serde_json::to_vec(document).map_err(|e| e.to_string())?;
67 let hash = atomic_repository::project_identity_hash(document);
68 let created_at = document
69 .get("dcterms:created")
70 .and_then(|v| v.as_str())
71 .unwrap_or_default()
72 .to_string();
73 Ok(ProjectIdentityRecord {
74 object,
75 hash,
76 mint_reason: atomic_core::kg::project_id::MintReason::Adopted,
77 created_at,
78 previous: None,
79 })
80}
81
82/// Fetch the remote's project identity and reconcile it into the local
83/// repository. Call after a successful clone/pull fetch.

Callers 2

apply_fetched_identityFunction · 0.85
adopt_from_remoteFunction · 0.85

Calls 3

project_identity_hashFunction · 0.85
getMethod · 0.65
as_strMethod · 0.45

Tested by

no test coverage detected