Struct Images

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

Handle for Podman Images.

Implementations§

Source§

impl Images

Source

pub fn new(podman: Podman) -> Self

Exports an interface for interacting with Podman Images.

Source

pub fn get(&self, id: impl Into<Id>) -> Image

Returns a reference to a set of operations available to a specific Image.

Source§

impl Images

Source

pub fn build( &self, opts: &ImageBuildOpts, ) -> Result<impl Stream<Item = Result<ImageBuildLibpod200Response>> + Unpin + '_>

Api Reference

Build an image from the given Dockerfile(s)

Examples:

async {
    use podman_api::Podman;
    use futures_util::StreamExt;
    use podman_api::opts::ImageBuildOpts;

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

    let opts = ImageBuildOpts::builder("http://some.url.to/Dockerfile")
            .tag("myimage:1.0.0")
            .build();

    let images = podman.images();
    match images.build(&opts) {
        Ok(mut build_stream) => while let Some(chunk) = build_stream.next().await {
            match chunk {
                Ok(chunk) => println!("{:?}", chunk),
                Err(e) => eprintln!("{}", e),
            }
        },
        Err(e) => eprintln!("{}", e),
    };
};
Source

pub async fn list( &self, opts: &ImageListOpts, ) -> Result<Vec<LibpodImageSummary>>

Api Reference

Returns a list of images.

Examples:

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

    for image in podman
        .images()
        .list(
            &ImageListOpts::builder()
                .all(true)
                .filter([ImageListFilter::Dangling(true)])
                .build(),
        )
        .await
        .unwrap()
    {
        println!("{:?}", image);
    }
};
Source

pub fn pull( &self, opts: &PullOpts, ) -> impl Stream<Item = Result<LibpodImagesPullReport>> + Unpin + '_

Api Reference

Pull one or more images from a container registry.

Examples:

async {
    use futures_util::{StreamExt, TryStreamExt};
    use podman_api::{Error, Podman};
    use podman_api::opts::PullOpts;
    let podman = Podman::unix("/run/user/1000/podman/podman.sock");

    let events = podman
        .images()
        .pull(
            &PullOpts::builder()
                .reference("docker.io/library/alpine")
                .build(),
            )
            .map(|report| {
                report.and_then(|report| match report.error {
                    Some(error) => Err(Error::InvalidResponse(error)),
                    None => Ok(report),
                })
            })
            .try_collect::<Vec<_>>()
            .await;

    if let Err(e) = events {
        eprintln!("{}", e);
    }
};
Source

pub async fn load(&self, image: impl AsRef<[u8]>) -> Result<ImageLoadReport>

Api Reference

Load an image (oci-archive or docker-archive) stream.

Examples:

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

    let image = std::fs::read("image_archive").unwrap();

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

pub async fn import( &self, opts: &ImageImportOpts, image: impl AsRef<[u8]>, ) -> Result<LibpodImagesPullReport>

Api Reference

Import a previously exported tarball as an image.

Examples:

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

    let image = vec![0, 1];

    if let Err(e) = podman
        .images()
        .import(
            &ImageImportOpts::builder()
                .reference("rockylinux/rockylinux:8")
                .build(),
            image
        )
        .await
    {
        eprintln!("{}", e);
    }
};
Source

pub async fn remove( &self, opts: &ImagesRemoveOpts, ) -> Result<LibpodImagesRemoveReport>

Api Reference

Remove multiple images. To remove a single image use Image::delete or Image::remove.

Examples:

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

    match podman
        .images()
        .remove(&ImagesRemoveOpts::builder().all(true).force(true).build())
        .await
    {
        Ok(info) => println!("{:?}", info),
        Err(e) => eprintln!("{}", e),
    }
};
Source

pub async fn prune( &self, opts: &ImagePruneOpts, ) -> Result<Option<Vec<PruneReport>>>

Api Reference

Remove images that are not being used by a container.

Examples:

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

    match podman
        .images()
        .prune(
            &ImagePruneOpts::builder()
                .all(true)
                .build()
        ).await {
            Ok(report) => println!("{:?}", report),
            Err(e) => eprintln!("{}", e),
    }
};
Source

pub async fn search( &self, opts: &ImageSearchOpts, ) -> Result<Vec<RegistrySearchResponse>>

Api Reference

Search registries for images.

Examples:

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

    match podman
        .images()
        .search(
            &ImageSearchOpts::builder()
                .list_tags(true)
                .build()
        ).await {
            Ok(images) => println!("{:?}", images),
            Err(e) => eprintln!("{}", e),
    }
};
Source

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

Api Reference

Export multiple images into a single object.

Examples:

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

    let full_id_a = "3290fj209...".to_string();
    let full_id_b = "ioajfoi32...".to_string();

    let export_opts = ImagesExportOpts::builder()
        .references([full_id_a, full_id_b])
        .build();

    let export_stream = images.export(&export_opts);
    let export_data = export_stream.try_concat().await.expect("images archive");
    assert!(!export_data.is_empty());
};

Trait Implementations§

Source§

impl Debug for Images

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Images

§

impl !RefUnwindSafe for Images

§

impl Send for Images

§

impl Sync for Images

§

impl Unpin for Images

§

impl !UnwindSafe for Images

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