#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.schema_version: u64Always LOCK_SCHEMA_VERSION.
tei: StringThe TEI that was resolved, as given.
server: StringThe API root that served the release, without userinfo, query or fragment.
api_version: StringThe advertised API version that was used.
spec_commit: StringThe TEA specification commit this client is pinned to.
product_release: StringProduct release UUID.
collection_version: u64Collection version that was locked.
artifacts: Vec<LockedArtifact>Artifacts, sorted by UUID then media type.
Implementations§
Source§impl LockFile
impl LockFile
Sourcepub 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
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.
Sourcepub fn validate(&self) -> Result<(), ModelError>
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.
Sourcepub fn to_json(&self) -> Result<String, ModelError>
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.
Sourcepub fn parse(bytes: &[u8]) -> Result<Self, ModelError>
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.