Unwrap an interchange envelope without converting its payload. Legacy v3 and empty labels remain accepted, including schema-5 bytes sent by older libatomic producers. A v5 label requires a v5 header. The caller must use core/repository validation for the authenticated descriptor and claimed hash.
(bundle: &pb::ChangeBundle)
| 348 | /// libatomic producers. A v5 label requires a v5 header. The caller must use |
| 349 | /// core/repository validation for the authenticated descriptor and claimed hash. |
| 350 | pub fn change_from_bundle(bundle: &pb::ChangeBundle) -> Result<(Hash, Vec<u8>), String> { |
| 351 | if !bundle.schema.is_empty() |
| 352 | && bundle.schema != CHANGE_SCHEMA |
| 353 | && bundle.schema != LEGACY_CHANGE_SCHEMA |
| 354 | { |
| 355 | return Err(format!( |
| 356 | "expected {CHANGE_SCHEMA} or {LEGACY_CHANGE_SCHEMA} change bytes, got '{}'", |
| 357 | bundle.schema |
| 358 | )); |
| 359 | } |
| 360 | if bundle.schema == CHANGE_SCHEMA |
| 361 | && change_file_header(&bundle.payload)?.version != FIELD_CODEC_FORMAT_VERSION |
| 362 | { |
| 363 | return Err("atomic.change.v5 requires an ATOM schema-5 payload".into()); |
| 364 | } |
| 365 | Ok(( |
| 366 | hash_from_proto(bundle.hash.as_ref())?, |
| 367 | bundle.payload.clone(), |
| 368 | )) |
| 369 | } |
| 370 | |
| 371 | pub fn provenance_graph_bytes(graph: Vec<u8>) -> pb::VersionedBytes { |
| 372 | versioned(PROVENANCE_GRAPH_SCHEMA, graph) |
no test coverage detected