pub trait AsyncBuilder<B: BuildableImage> {
// Required methods
fn build_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<B::Built>> + Send + 'async_trait>>
where Self: 'async_trait;
fn build_image_with<'async_trait>(
self,
options: BuildImageOptions,
) -> Pin<Box<dyn Future<Output = Result<B::Built>> + Send + 'async_trait>>
where Self: 'async_trait;
}Required Methods§
fn build_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<B::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
fn build_image_with<'async_trait>(
self,
options: BuildImageOptions,
) -> Pin<Box<dyn Future<Output = Result<B::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T> AsyncBuilder<T> for Twhere
T: BuildableImage + Send,
Helper trait to build Docker images asynchronously from BuildableImage instances.
Provides an asynchronous interface for building custom Docker images within test environments.
This trait is automatically implemented for any type that implements BuildableImage + Send.
§Example
use testcontainers::{core::WaitFor, runners::AsyncBuilder, runners::AsyncRunner, GenericBuildableImage};
#[test]
async fn test_custom_image() -> anyhow::Result<()> {
let image = GenericBuildableImage::new("my-test-app", "latest")
.with_dockerfile_string("FROM alpine:latest\nRUN echo 'hello'")
.build_image()?.await;
// Use the built image in containers
let container = image
.with_wait_for(WaitFor::message_on_stdout("Hello from test!"))
.start()?.await;
Ok(())
}