pub struct Image { /* private fields */ }Expand description
Represents an OCI image with its metadata and manifest.
Implementations§
Source§impl Image
impl Image
Sourcepub fn open(storage: &Storage, id: &str) -> Result<Self>
pub fn open(storage: &Storage, id: &str) -> Result<Self>
Open an image by ID using fd-relative operations.
The ID can be provided with or without a sha256: prefix - the prefix
will be stripped if present, since containers-storage directories use
just the hex digest.
§Errors
Returns an error if the image directory doesn’t exist or cannot be opened.
Sourcepub fn read_manifest_raw(&self) -> Result<Vec<u8>>
pub fn read_manifest_raw(&self) -> Result<Vec<u8>>
Read the raw manifest JSON bytes.
Returns the original manifest bytes as stored on disk, preserving whitespace and field ordering for content-addressed hashing.
§Errors
Returns an error if the manifest file cannot be read.
Sourcepub fn manifest(&self) -> Result<ImageManifest>
pub fn manifest(&self) -> Result<ImageManifest>
Read and parse the image manifest.
The manifest is stored as a JSON file named “manifest” in the image directory.
§Errors
Returns an error if the manifest file cannot be read or parsed.
Sourcepub fn config(&self) -> Result<ImageConfiguration>
pub fn config(&self) -> Result<ImageConfiguration>
Read and parse the image configuration.
The image config is stored with a base64-encoded key based on the image digest.
§Errors
Returns an error if the config file cannot be read or parsed.
Sourcepub fn layers(&self) -> Result<Vec<String>>
pub fn layers(&self) -> Result<Vec<String>>
Get the OCI diff_ids for this image in order (base to top).
This returns the diff_ids from the image config, which are the uncompressed
tar digests. Note that these are not the same as the storage layer IDs!
To get the actual storage layer IDs, use storage_layer_ids().
§Errors
Returns an error if the config cannot be read or parsed.
Sourcepub fn storage_layer_ids(&self, stores: &[Storage]) -> Result<Vec<String>>
pub fn storage_layer_ids(&self, stores: &[Storage]) -> Result<Vec<String>>
Get the storage layer IDs for this image in order (base to top).
Unlike layers() which returns OCI diff_ids, this method
returns the actual storage layer directory names by resolving diff_ids
through the layers.json mapping file.
§Errors
Returns an error if the config cannot be read, parsed, or if any layer cannot be resolved.