| 388 | } |
| 389 | |
| 390 | pub fn publication_proto( |
| 391 | publication: &SessionCheckpointPublication, |
| 392 | ) -> Result<pb::ProvenancePublished, String> { |
| 393 | let published_at = publication.turn.timestamp_datetime().ok_or_else(|| { |
| 394 | "session publication timestamp is outside the supported range".to_string() |
| 395 | })?; |
| 396 | Ok(pb::ProvenancePublished { |
| 397 | provenance_hash: Some(hash_proto(&publication.turn.provenance_hash)), |
| 398 | published_at: Some(super::convert::timestamp_proto(published_at)), |
| 399 | manifest_hash: Some(hash_proto(&publication.manifest_hash)), |
| 400 | publication: Some(versioned( |
| 401 | PUBLICATION_SCHEMA, |
| 402 | serde_json::to_vec(publication).map_err(|e| e.to_string())?, |
| 403 | )), |
| 404 | }) |
| 405 | } |
| 406 | |
| 407 | pub fn publication_from( |
| 408 | published: &pb::ProvenancePublished, |