Skip to main content

Image

Struct Image 

Source
pub struct Image { /* private fields */ }
Expand description

Represents an OCI image with its metadata and manifest.

Implementations§

Source§

impl Image

Source

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.

Source

pub fn id(&self) -> &str

Get the image ID.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn read_metadata(&self, key: &str) -> Result<Vec<u8>>

Read additional metadata files.

Metadata files are stored with base64-encoded keys as filenames, prefixed with ‘=’.

§Errors

Returns an error if the metadata file doesn’t exist or cannot be read.

Source

pub fn image_dir(&self) -> &Dir

Get a reference to the image directory handle.

Source

pub fn names(&self, storage: &Storage) -> Result<Vec<String>>

Get the repository names/tags for this image.

Reads from the overlay-images/images.json index file to find the names associated with this image.

§Errors

Returns an error if the images.json file cannot be read or parsed.

Trait Implementations§

Source§

impl Debug for Image

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Image

§

impl RefUnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnsafeUnpin for Image

§

impl UnwindSafe for Image

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.