ImagePruneExistedLabelExt

Trait ImagePruneExistedLabelExt 

Source
pub trait ImagePruneExistedLabelExt<I>:
    Sized
    + ImageExt<I>
    + Send
where I: Image,
{ // Provided method fn with_prune_existed_label( self, scope: &str, container_label: &str, prune: bool, force: bool, ) -> impl Future<Output = Result<ContainerRequest<I>, TestcontainersError>> + Send { ... } }

Provided Methods§

Source

fn with_prune_existed_label( self, scope: &str, container_label: &str, prune: bool, force: bool, ) -> impl Future<Output = Result<ContainerRequest<I>, TestcontainersError>> + Send

Given a scope, a container label, a prune flag, and a force flag, this method will prune the container if the prune flag is true.

Example:

use tokio::runtime::Runtime;
use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, GenericImage, ImageExt};
use testcontainers_ext::ImagePruneExistedLabelExt;
use anyhow::Result;

async fn test () -> Result<()> {
  let container = GenericImage::new("redis", "7.2.4")
        .with_exposed_port(6379.tcp())
        .with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
        .with_prune_existed_label("my-project-scope", "redis", true, true).await?
        .start()
        .await?;
   Ok(())
}

Runtime::new().unwrap().block_on(test()).unwrap();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<R, I> ImagePruneExistedLabelExt<I> for R
where R: Sized + ImageExt<I> + Send, I: Image,