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<ContainerRequest<I>>> + Send + 'async_trait>>
where Self: 'async_trait;
}
Expand description
Helper trait to start containers asynchronously.
§Example
use testcontainers::{core::{WaitFor, IntoContainerPort}, runners::AsyncRunner, GenericImage};
async fn test_redis() {
let container = GenericImage::new("redis", "7.2.4")
.with_exposed_port(6379.tcp())
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.start()
.await;
}
Required Methods§
Sourcefn start<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerAsync<I>>> + Send + 'async_trait>>where
Self: 'async_trait,
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
.
Sourcefn pull_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerRequest<I>>> + Send + 'async_trait>>where
Self: 'async_trait,
fn pull_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerRequest<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.