pub struct ProvenanceRecord {
pub version: u16,
pub asset_id: Uuid,
pub manifest: AssetManifest,
pub prior_provenance_hash: Option<Hash32>,
}Expand description
One link in an asset’s provenance chain.
The record leads with its version (Versioning — invariant 2): the key
sorts first in canonical CBOR, and decode reads it before anything else,
so a record from a newer writer is recognised as such rather than misread as this version.
Every other decode path refuses it too, because the field’s own decoder rejects a version
this build does not implement.
Fields§
§version: u16The record schema version; PROVENANCE_RECORD_VERSION on every record this build
writes.
asset_id: UuidThe asset this chain belongs to.
manifest: AssetManifestThe signed manifest for this transition.
prior_provenance_hash: Option<Hash32>SHA-256 of the previous record; null only for action = create. Mirrors the
manifest’s own prior_provenance_hash, so signing the manifest signs this link.
Implementations§
Source§impl ProvenanceRecord
impl ProvenanceRecord
Sourcepub fn new(
asset_id: Uuid,
manifest: AssetManifest,
prior: Option<Hash32>,
) -> Self
pub fn new( asset_id: Uuid, manifest: AssetManifest, prior: Option<Hash32>, ) -> Self
A current-version record linking manifest into asset_id’s chain behind prior.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, RecordDecodeError>
pub fn decode(bytes: &[u8]) -> Result<Self, RecordDecodeError>
Decode one record, reading its leading version before anything else.
§Errors
RecordDecodeError::UnsupportedVersion for a record a newer writer produced — the
caller quarantines it — and RecordDecodeError::Malformed for anything else that does
not decode, including a missing or non-integer version.
Sourcepub fn record_hash(&self) -> Hash32
pub fn record_hash(&self) -> Hash32
The content hash of this record (SHA-256 over its canonical CBOR, signatures
included), used as the next record’s prior_provenance_hash.
Sourcepub fn mirrors_manifest(&self) -> bool
pub fn mirrors_manifest(&self) -> bool
Whether the manifest’s prior_provenance_hash mirrors the record’s, as required.
Public because the chain walker is not the only checker: capsule-library’s
Workspace::apply_remote_entry decodes a record straight off the wire and must run the
same check before it trusts either copy. provenance.md’s Chained, Append-Only Structure
is explicit that the two copies are “a checked invariant, not trusted redundancy”, and a
checker that lived in one place would leave the wire path unchecked.
Trait Implementations§
Source§impl Clone for ProvenanceRecord
impl Clone for ProvenanceRecord
Source§fn clone(&self) -> ProvenanceRecord
fn clone(&self) -> ProvenanceRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProvenanceRecord
impl Debug for ProvenanceRecord
Source§impl<'de> Deserialize<'de> for ProvenanceRecord
impl<'de> Deserialize<'de> for ProvenanceRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ProvenanceRecord
Source§impl PartialEq for ProvenanceRecord
impl PartialEq for ProvenanceRecord
Source§fn eq(&self, other: &ProvenanceRecord) -> bool
fn eq(&self, other: &ProvenanceRecord) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ProvenanceRecord
impl Serialize for ProvenanceRecord
impl StructuralPartialEq for ProvenanceRecord
Auto Trait Implementations§
impl Freeze for ProvenanceRecord
impl RefUnwindSafe for ProvenanceRecord
impl Send for ProvenanceRecord
impl Sync for ProvenanceRecord
impl Unpin for ProvenanceRecord
impl UnsafeUnpin for ProvenanceRecord
impl UnwindSafe for ProvenanceRecord
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more