Struct contain_rs::Container

source ·
pub struct Container {
    pub name: String,
    pub image: Image,
    pub command: Vec<String, Global>,
    pub network: Option<Network>,
    pub volumes: Vec<Volume, Global>,
    pub port_mappings: Vec<PortMapping, Global>,
    pub env_vars: Vec<EnvVar, Global>,
    pub health_check: Option<HealthCheck>,
    pub wait_strategy: Option<WaitStrategy>,
    pub additional_wait_period: Duration,
}
Expand description

A container makes up the schedulable unit of this crate.

You can define an Image for it to be used and define port mappings and environment variables on it for example.

Fields§

§name: String§image: Image§command: Vec<String, Global>§network: Option<Network>§volumes: Vec<Volume, Global>§port_mappings: Vec<PortMapping, Global>§env_vars: Vec<EnvVar, Global>§health_check: Option<HealthCheck>§wait_strategy: Option<WaitStrategy>§additional_wait_period: Duration

Implementations§

source§

impl Container

source

pub fn from_image(image: Image) -> Container

Creates a new container from and Image

source

pub fn name(&mut self, name: &str) -> &mut Container

Define a specific name for the container.

In case no explicit name is defined contain-rs will generate one as the name is being used by the crate::client::Client for interaction.

source

pub fn command(&mut self, command: Vec<String, Global>) -> &mut Container

Define an explicit command to run in the container.

source

pub fn arg<T>(&mut self, arg: T) -> &mut Containerwhere T: Into<String>,

source

pub fn map_ports<T, T2>(&mut self, ports: &[(T, T2)]) -> &mut Containerwhere T: Into<Port> + Clone, T2: Into<Port> + Clone,

source

pub fn volume(&mut self, name: &str, mount_point: &str) -> &mut Container

source

pub fn mount(&mut self, host_path: &str, mount_point: &str) -> &mut Container

source

pub fn map_port( &mut self, source: impl Into<Port>, target: impl Into<Port> ) -> &mut Container

Map a port from source on the host to target in the container.

source

pub fn env_var<T>(&mut self, name: T, value: T) -> &mut Containerwhere T: Into<String>,

Define an environment variable for the container.

source

pub fn wait_for(&mut self, strategy: WaitStrategy) -> &mut Container

Add a WaitStrategy to be used when running the container.

source

pub fn additional_wait_period(&mut self, period: Duration) -> &mut Container

Add some additional wait time for concidering the container healthy.

Contain-rs waits this additional time after the WaitStrategy has been concidered successful.

source

pub fn health_check(&mut self, health_check: HealthCheck) -> &mut Container

Add an arbitrary healthcheck to the container.

Some images may define healthchecks already, yet you can use this one to define one yourself explicitly.

Trait Implementations§

source§

impl Clone for Container

source§

fn clone(&self) -> Container

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 From<Image> for Container

source§

fn from(image: Image) -> Container

Converts to this type from the input type.
source§

impl IntoContainer for Container

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
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 Twhere 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 Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

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