Skip to main content

SyncRunner

Trait SyncRunner 

Source
pub trait SyncRunner<I: Image> {
    // Required methods
    fn start(self) -> Result<Container<I>>;
    fn pull_image(self) -> Result<ContainerRequest<I>>;
}
Available on crate feature blocking only.
Expand description

Helper trait to start containers synchronously.

§Example

use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::SyncRunner, GenericImage};

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()
        .unwrap();
}

Required Methods§

Source

fn start(self) -> Result<Container<I>>

Starts the container and returns an instance of Container.

Source

fn pull_image(self) -> Result<ContainerRequest<I>>

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, I> SyncRunner<I> for T
where T: Into<ContainerRequest<I>> + Send, I: Image,