Skip to main content

ToolchainLockfileExt

Trait ToolchainLockfileExt 

Source
pub trait ToolchainLockfileExt: Sized {
    // Required methods
    fn new() -> Self;
    fn load(path: &Path) -> Result<Option<Self>>;
    fn save(&self, path: &Path) -> Result<()>;
    fn lookup(
        &self,
        tool: &str,
        platform: &str,
        arch: &str,
    ) -> Option<&LockedTool>;
    fn upsert(&mut self, entry: LockedTool);
}
Expand description

I/O + query extension methods for the pure-serde ToolchainLockfile.

Implemented as an extension trait because the type is defined in zlayer-types (which must stay free of tokio/toml I/O), yet the file operations belong here in the provisioning crate. With this trait in scope, ToolchainLockfile::new() / ToolchainLockfile::load(path) and lock.save(path) / lock.lookup(..) / lock.upsert(..) all read naturally.

Required Methods§

Source

fn new() -> Self

A fresh, empty lockfile stamped with the current schema + timestamp.

Source

fn load(path: &Path) -> Result<Option<Self>>

Load a lockfile from path.

Returns Ok(None) when the file is absent (a cold repo), a loud ToolchainError::CacheError on a parse failure or a schema mismatch, and Ok(Some(..)) otherwise.

§Errors

Returns ToolchainError::CacheError on a corrupt file or an unsupported schema, and ToolchainError::IoError on a read failure other than “not found”.

Source

fn save(&self, path: &Path) -> Result<()>

Serialize to TOML at path with a stable (tool, platform, arch) order.

§Errors

Returns ToolchainError::CacheError on a serialization failure and ToolchainError::IoError on a write failure.

Source

fn lookup(&self, tool: &str, platform: &str, arch: &str) -> Option<&LockedTool>

The pinned entry for (tool, platform, arch), if present.

Source

fn upsert(&mut self, entry: LockedTool)

Insert entry, replacing any existing pin for its (tool, platform, arch).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§