Skip to main content

Provenance

Struct Provenance 

Source
#[non_exhaustive]
pub struct Provenance {
Show 13 fields pub format: String, pub kind: ProvenanceKind, pub id: String, pub files: Vec<ArtifactFile>, pub revision: String, pub origin: String, pub license: Option<String>, pub base: Option<ProvenanceBase>, pub dataset: Option<ProvenanceDataset>, pub trainer: Option<ProvenanceTrainer>, pub uploaded_by: Option<String>, pub uploaded_ms: Option<u64>, pub extra: BTreeMap<String, Value>,
}
Expand description

Where a model, adapter or projector came from, kept next to its files (PROVENANCE_FILE). It is what the uploader said, checked against the bytes where it can be (files, hashes and revision are set from them on import); it is signed by nobody and is not a trust anchor. Unknown fields (an app’s own) are kept in Provenance::extra and written back.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§format: String

PROVENANCE_FORMAT, or an app’s own name.

§kind: ProvenanceKind§id: String§files: Vec<ArtifactFile>§revision: String

See revision.

§origin: String

ORIGIN_UPLOAD, ORIGIN_TRAIN, ORIGIN_HUB or an app’s own.

§license: Option<String>

An SPDX id, or unknown when the uploader said so explicitly.

§base: Option<ProvenanceBase>§dataset: Option<ProvenanceDataset>§trainer: Option<ProvenanceTrainer>§uploaded_by: Option<String>

The uploading device’s label.

§uploaded_ms: Option<u64>

Unix time in milliseconds.

§extra: BTreeMap<String, Value>

Any other fields.

Implementations§

Source§

impl Provenance

Source

pub fn new(origin: impl Into<String>) -> Self

A record with this origin (ORIGIN_UPLOAD and so on).

Source

pub fn for_artifact( artifact: &Artifact, id: impl Into<String>, origin: impl Into<String>, ) -> Self

A record for artifact stored as id: its kind, files and revision, and its base model’s Hub id when the files name one.

Source

pub fn with_license(self, license: impl Into<String>) -> Self

Source

pub fn size(&self) -> u64

Bytes of the files it lists.

Source

pub fn read(dir: &Path) -> Option<Provenance>

The record in dir (PROVENANCE_FILE), if there is a readable one.

Source

pub fn write(&self, dir: &Path) -> Result<()>

Writes the record to dir (PROVENANCE_FILE), replacing it atomically.

Trait Implementations§

Source§

impl Clone for Provenance

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Provenance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Provenance

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Provenance

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Provenance

Source§

impl PartialEq for Provenance

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Provenance

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Provenance

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.