Trait testcontainers::runners::AsyncRunner

source ·
pub trait AsyncRunner<I: Image> {
    // Required methods
    fn start<'async_trait>(
        self
    ) -> Pin<Box<dyn Future<Output = Result<ContainerAsync<I>>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn pull_image<'async_trait>(
        self
    ) -> Pin<Box<dyn Future<Output = Result<RunnableImage<I>>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

Helper trait to start containers asynchronously.

§Example

use testcontainers::{core::WaitFor, runners::AsyncRunner, GenericImage};

async fn test_redis() {
    let container = GenericImage::new("redis", "7.2.4")
        .with_exposed_port(6379)
        .with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
        .start()
        .await;
}

Required Methods§

source

fn start<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Result<ContainerAsync<I>>> + Send + 'async_trait>>
where Self: 'async_trait,

Starts the container and returns an instance of ContainerAsync.

source

fn pull_image<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Result<RunnableImage<I>>> + Send + 'async_trait>>
where Self: 'async_trait,

Pulls the image from the registry. Useful if you want to pull the image before starting the container.

Implementors§

source§

impl<T, I> AsyncRunner<I> for T
where T: Into<RunnableImage<I>> + Send, I: Image,