pub async fn fetch_and_verify_data_ref(
dr: &DataRef,
fetcher: &impl DataRefFetcher,
) -> Result<Vec<u8>, AcdpError>Expand description
Convenience: fetch a DataRef and verify its declared
content_hash.
Behavior:
- Embedded ref: returns the decoded bytes via
acdp_validation::embedded_decoded_bytes. If the ref also declares acontent_hash,acdp_validation::verify_embedded_hashhas already verified it at validation time; this function re-verifies as a defense-in-depth check. - URI ref: delegates to
fetcherand recomputes SHA-256 over the returned bytes, checking againstdr.content_hashwhen present. Ifcontent_hashis absent, returns the bytes unverified — the producer chose not to commit to a hash, so the consumer is on its own. - Both URI and embedded: rejected at validation; this function relies on that and assumes exactly one is present.