[][src]Struct dockertest::Composition

pub struct Composition { /* fields omitted */ }

Represents an instance of an Image. The Composition is used to specialize an Image whose name, version, tag and source is known, but before one can create a RunningContainer from an Image, it must be augmented with information about how to start it, how to ensure it has been started, environment variables and runtime commands. Thus, this structure represents the concrete instance of an Image that will be started and become a RunningContainer.

Examples

let mut hello = Composition::with_repository("hello-world")
    .with_container_name("my-hello-world")
    .with_cmd(vec!["command".to_string(), "arg".to_string()]);
hello.env("MY_ENV", "MY VALUE");
hello.cmd("appended_to_original_cmd!");

Methods

impl Composition[src]

pub fn with_repository<T: ToString>(repository: T) -> Composition[src]

Creates a Composition based on the Image repository name provided. This will internally create the Image based on the provided repository name, and default the tag to latest.

This is the shortcut method of constructing a Composition. See with_image to create one with a provided Image.

pub fn with_image(image: Image) -> Composition[src]

Creates a Composition with the provided Image. This is the long-winded way of defining a Composition. See with_repository to for the shortcut method.

pub fn with_start_policy(self, start_policy: StartPolicy) -> Composition[src]

Sets the start_policy for this Composition. Defaults to a relaxed policy.

pub fn with_env(self, env: HashMap<String, String>) -> Composition[src]

Assigns the full set of environmental variables available for the RunningContainer. Each key in the map should be the environmental variable name and its corresponding value will be set as its value.

This method replaces the entire existing env map provided.

pub fn with_cmd(self, cmd: Vec<String>) -> Composition[src]

Sets the command of the container.

If no entries in the command vector is provided to the Composition, the command within the Image will be used, if any.

pub fn with_container_name<T: ToString>(self, container_name: T) -> Composition[src]

Sets the name of the container that will eventually be started. This is merely part of the final container name, and the full container name issued to docker will be generated. The container name assigned here is also used to resolve the handle concept used by dockertest.

The container name defaults to the repository name.

pub fn with_wait_for(self, wait: Rc<dyn WaitFor>) -> Composition[src]

Sets the wait_for trait object for this Composition.

The default WaitFor implementation used is RunningWait.

pub fn env<T: ToString, S: ToString>(
    &mut self,
    name: T,
    value: S
) -> &mut Composition
[src]

Sets the environment variable to the given value.

NOTE: if with_env is called after a call to env, all values added by env will be overwritten.

pub fn cmd<T: ToString>(&mut self, cmd: T) -> &mut Composition[src]

Appends the command string to the current command vector.

If no entries in the command vector is provided to the Composition, the command within the Image will be used, if any.

NOTE: if with_cmd is called after a call to cmd, all entries to the command vector added with cmd will be overwritten.

pub fn port_map(&mut self, exported: u32, host: u32) -> &mut Composition[src]

Adds the exported -> host port mapping. If an exported port already exists, it will be overridden.

Trait Implementations

impl Clone for Composition[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]