Struct Image

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

Interface for accessing and manipulating Podman Image.

Api Reference

Implementations§

Source§

impl Image

Source

pub fn new(podman: Podman, id: impl Into<Id>) -> Self

Exports an interface exposing operations against a Image instance.

Source

pub fn id(&self) -> &Id

A getter for Image id

Source§

impl Image

Source

pub async fn inspect(&self) -> Result<InspectImageResponseLibpod>

Api Reference

Obtain low-level information about this image.

Examples:

async {
    use podman_api::Podman;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    match podman.images().get("debian").inspect().await {
        Ok(info) => println!("{:?}", info),
        Err(e) => eprintln!("{}", e),
    }
};
Source

pub async fn history(&self) -> Result<Vec<HistoryResponse>>

Api Reference

Return parent layers of an image.

Examples:

async {
    use podman_api::Podman;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    match podman.images().get("debian").history().await {
        Ok(info) => println!("{:?}", info),
        Err(e) => eprintln!("{}", e),
    }
};
Source

pub async fn exists(&self) -> Result<bool>

Api Reference

Quick way to determine if a image exists by name or ID.

Examples:

async {
    use podman_api::Podman;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    match podman.images().get("debian").exists().await {
        Ok(exists) => if exists {
            println!("image exists!");
        } else {
            println!("image doesn't exists!");
        },
        Err(e) => eprintln!("check failed: {}", e),
    }
};
Source

pub async fn delete(&self) -> Result<()>

Api Reference

Delete this image from local storage. To forcefully remove an image use Image::remove.

Examples:

async {
    use podman_api::Podman;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    if let Err(e) = podman.images().get("debian").delete().await {
        eprintln!("{}", e);
    }
};
Source

pub async fn remove(&self) -> Result<()>

Api Reference

Remove this image forcefully from local storage. To remove the image normally use Image::delete.

Examples:

async {
    use podman_api::Podman;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    if let Err(e) = podman.images().get("debian").remove().await {
        eprintln!("{}", e);
    }
};
Source

pub async fn tag(&self, opts: &ImageTagOpts) -> Result<()>

Api Reference

Tag an image so that it becomes part of a repository.

Examples:

async {
    use podman_api::Podman;
    use podman_api::opts::ImageTagOpts;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    if let Err(e) = podman
        .images()
        .get("debian")
        .tag(
            &ImageTagOpts::builder()
                .repo("my.custom.repo/debian")
                .tag("1.0.0")
                .build(),
        )
        .await
    {
        eprintln!("{}", e);
    }
};
Source

pub async fn untag(&self, opts: &ImageTagOpts) -> Result<()>

Api Reference

Untag an image. If repo and tag are not specified, all tags are removed from the image.

Examples:

async {
    use podman_api::Podman;
    use podman_api::opts::ImageTagOpts;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    if let Err(e) = podman
        .images()
        .get("debian")
        .untag(
            &ImageTagOpts::builder()
                .repo("my.custom.repo/debian")
                .tag("1.0.0")
                .build(),
        )
        .await
    {
        eprintln!("{}", e);
    }
};
Source

pub fn export( &self, opts: &ImageExportOpts, ) -> impl Stream<Item = Result<Vec<u8>>> + Unpin + '_

Api Reference

Export this image.

Examples:

async {
    use podman_api::Podman;
    use futures_util::stream::TryStreamExt;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");
    let image = podman.images().get("myimage");

    let export_stream = image.export(&Default::default());
    let export_data = export_stream.try_concat().await.expect("image archive");
    assert!(!export_data.is_empty());
};
Source

pub async fn changes( &self, opts: &ChangesOpts, ) -> Result<Vec<ContainerChangeResponseItem>>

Api Reference

Returns which files in this image’s filesystem have been added, deleted, or modified.

Examples:

async {
    use podman_api::Podman;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    match podman
        .images()
        .get("79c93f220e3e")
        .changes(&Default::default())
        .await
    {
        Ok(changes) => println!("{:?}", changes),
        Err(e) => eprintln!("{}", e),
    }
};
Source

pub async fn tree(&self, opts: &ImageTreeOpts) -> Result<TreeResponse>

Api Reference

Retrieve the image tree for this image.

Examples:

async {
    use podman_api::Podman;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    match podman
        .images()
        .get("79c93f220e3e")
        .tree(&Default::default())
        .await
    {
        Ok(tree) => println!("{:?}", tree),
        Err(e) => eprintln!("{}", e),
    }
};
Source

pub async fn push(&self, opts: &ImagePushOpts) -> Result<String>

Api Reference

Push this image to a container registry.

Examples:

async {
    use podman_api::Podman;
    use podman_api::opts::{RegistryAuth, ImagePushOpts};
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    match podman.images().get("alpine").push(
        &ImagePushOpts::builder()
            .destinations("my-destination")
            .tls_verify(true)
            .auth(
                RegistryAuth::builder()
                    .username("test")
                    .password("test")
                    .server_address("https://my-registry")
                    .build(),
            )
            .build(),
    ).await {
        Ok(s) => println!("{}", s),
        Err(e) => eprintln!("{}", e),
    };
};

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 !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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T