rustainers::runner

Enum Runner

Source
#[non_exhaustive]
pub enum Runner { Docker(Docker), Podman(Podman), Nerdctl(Nerdctl), }
Expand description

The test containers runner

Use the Runner::auto, Runner::docker, Runner::podman, Runner::nerdctl functions to create your runner

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Docker(Docker)

Docker

§

Podman(Podman)

Podman

§

Nerdctl(Nerdctl)

Nerdctl

Implementations§

Source§

impl Runner

Source

pub fn auto() -> Result<Self, RunnerError>

Find an available runner

§Errors

Fail if no runner is available

Source

pub fn docker() -> Result<Self, RunnerError>

Create a docker runner

§Errors

Fail if the docker command is not found Fail if the docker command version is unsupported

Source

pub fn podman() -> Result<Self, RunnerError>

Create a podman runner

§Errors

Fail if the podman command is not found Fail if the podman command version is unsupported

Source

pub fn nerdctl() -> Result<Self, RunnerError>

Create a nerdctl runner

§Errors

Fail if the nerdctl command is not found Fail if the nerdctl command version is unsupported

Source§

impl Runner

Source

pub async fn start<I>(&self, image: I) -> Result<Container<I>, RunnerError>

Start a runnable container

The default RunOption is used

§Errors

Fail if we cannot launch the container

Source

pub async fn start_with_options<I>( &self, image: I, options: RunOption, ) -> Result<Container<I>, RunnerError>

Start a runnable container with option

§Errors

Fail if we cannot launch the container

Source

pub async fn create_network( &self, name: impl Into<String>, ) -> Result<Network, RunnerError>

Create a network

§Errors

Could fail if we cannot execute the command

Source

pub async fn create_volume( &self, name: impl Into<String>, ) -> Result<VolumeName, RunnerError>

Create a container volume

§Errors

Could fail if we cannot execute the command

Source

pub async fn network_ip<I>( &self, container: &Container<I>, network: &Network, ) -> Result<Ipv4Addr, RunnerError>

Get the container IP for a custom network

§Errors

Fail if the network is not custom Fail if the IP is not found Could fail if we cannot execute the inspect command

Source

pub async fn container_host_ip(&self) -> Result<Ipv4Addr, RunnerError>

Get the container host ip

§Errors

Could fail if we cannot execute the inspect command

Source

pub async fn exec<I, S>( &self, container: &Container<I>, exec_command: impl IntoIterator<Item = S> + Debug, ) -> Result<String, RunnerError>

Execute a command into the container

§Errors

Could fail if we cannot execute the command

Source

pub fn stop<I>(&self, container: &Container<I>) -> Result<(), RunnerError>

Stop the container

This method is call during the crate::Container drop if it’s not detached

§Errors

Fail if we cannot launch the container

Source§

impl Runner

Source

pub async fn compose_start<I>( &self, images: I, ) -> Result<ComposeContainers<I>, RunnerError>

Run a compose container with the default options

§Errors

Fail if the compose containers cannot be started

Source

pub async fn compose_start_with_options<I>( &self, images: I, options: ComposeRunOption, ) -> Result<ComposeContainers<I>, RunnerError>

Run compose containers with options

§Errors

Fail if the compose containers cannot be started

Source§

impl Runner

Source

pub async fn copy_to_volume( &self, volume: VolumeName, path: impl AsRef<Path>, ) -> Result<(), CopyError>

Copy a file or a folder into a volume

§Errors

Fail if the path does not exists Fail if the path does not have a parent Fail if the path does not have a name Fail if the we cannot launch the copy into the containers

Trait Implementations§

Source§

impl Clone for Runner

Source§

fn clone(&self) -> Runner

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Runner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Runner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Runner

Source§

fn eq(&self, other: &Runner) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Runner

Source§

impl StructuralPartialEq for Runner

Auto Trait Implementations§

§

impl Freeze for Runner

§

impl RefUnwindSafe for Runner

§

impl Send for Runner

§

impl Sync for Runner

§

impl Unpin for Runner

§

impl UnwindSafe for Runner

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T