Skip to main content

LockFile

Struct LockFile 

Source
#[non_exhaustive]
pub struct LockFile { pub schema_version: u64, pub tei: String, pub server: String, pub api_version: String, pub spec_commit: String, pub product_release: String, pub collection_version: u64, pub artifacts: Vec<LockedArtifact>, }
Expand description

A lock file, schemaVersion 1.

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.
§schema_version: u64§tei: String

The TEI that was resolved, as given.

§server: String

The API root that served the release, without userinfo, query or fragment.

§api_version: String

The advertised API version that was used.

§spec_commit: String

The TEA specification commit this client is pinned to.

§product_release: String

Product release UUID.

§collection_version: u64

Collection version that was locked.

§artifacts: Vec<LockedArtifact>

Artifacts, sorted by UUID then media type.

Implementations§

Source§

impl LockFile

Source

pub fn new( tei: impl Into<String>, server: impl Into<String>, api_version: impl Into<String>, spec_commit: impl Into<String>, product_release: impl Into<String>, collection_version: u64, ) -> Self

Start a lock with no artifacts.

Source

pub fn normalize(&mut self)

Put artifacts and checksums into their canonical order.

Source

pub fn validate(&self) -> Result<(), ModelError>

Check the lock is one this crate would write.

§Errors

Returns an error for an unsupported schemaVersion, a server that could carry a secret, an identifier or timestamp that does not parse, a checksum that is not valid, or two entries for the same artifact and media type.

Source

pub fn to_json(&self) -> Result<String, ModelError>

Serialise in the canonical form: validated, sorted, two-space indent, camelCase keys in a fixed order, one trailing newline. The same content always yields the same bytes.

§Errors

Returns an error when LockFile::validate fails.

Source

pub fn parse(bytes: &[u8]) -> Result<Self, ModelError>

Parse and validate a lock file.

Unknown fields are rejected: the format is ours and version-gated, so a field this reader does not know means a newer schemaVersion, and silently dropping it on the next write would lose data.

§Errors

Returns an error for malformed JSON, an unsupported schemaVersion, an unknown field, or a lock that fails LockFile::validate.

Trait Implementations§

Source§

impl Clone for LockFile

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 LockFile

Source§

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

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

impl<'de> Deserialize<'de> for LockFile

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 LockFile

Source§

impl PartialEq for LockFile

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 LockFile

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 LockFile

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.