pub trait AsyncBuilder<B: BuildableImage> {
// Required method
fn build_image<'async_trait>(
self,
) -> 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,
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(())
}