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)
| 63 | /// Build a transport record from a fetched identity document: recompute the |
| 64 | /// canonical hash, mark it `Adopted` (it was never minted locally). |
| 65 | fn 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. |
no test coverage detected