| 347 | } |
| 348 | |
| 349 | pub fn publication_proto( |
| 350 | publication: &SessionCheckpointPublication, |
| 351 | ) -> Result<pb::ProvenancePublished, String> { |
| 352 | let published_at = publication.turn.timestamp_datetime().ok_or_else(|| { |
| 353 | "session publication timestamp is outside the supported range".to_string() |
| 354 | })?; |
| 355 | Ok(pb::ProvenancePublished { |
| 356 | provenance_hash: Some(hash_proto(&publication.turn.provenance_hash)), |
| 357 | published_at: Some(super::convert::timestamp_proto(published_at)), |
| 358 | manifest_hash: Some(hash_proto(&publication.manifest_hash)), |
| 359 | publication: Some(versioned( |
| 360 | PUBLICATION_SCHEMA, |
| 361 | serde_json::to_vec(publication).map_err(|e| e.to_string())?, |
| 362 | )), |
| 363 | }) |
| 364 | } |
| 365 | |
| 366 | pub fn publication_from( |
| 367 | published: &pb::ProvenancePublished, |