Struct Container

Source
pub struct Container<F, E>
where F: Fn() -> Result<(), E>, E: Error,
{ /* private fields */ }
Expand description

Represents a podman container.

This struct abstracts starting, stopping, and removing the container. The generic callback F allows running custom logic after the container is first created.

Implementations§

Source§

impl<F, E> Container<F, E>
where F: Fn() -> Result<(), E>, E: Error,

Source

pub fn new<N, I, A>(name: N, image: I, args: Vec<A>, callback: F) -> Self
where N: Into<String>, I: Into<String>, A: Into<String>,

Creates a new container instance.

§Arguments
  • name - The name of the container.
  • image - The container image to use.
  • args - Additional arguments to pass to the podman run command.
  • callback - A callback function executed after the container starts.
Source

pub fn start(&self) -> Result<(), ContainerError<E>>

Starts the container.

  • If the container is already running, this is a no-op.
  • If the container is stopped, paused, or exited, it will be started.
  • If the container does not exist, it will be created and started, and the callback function will be run.
Source

pub fn stop(&self, remove: bool) -> Result<(), ContainerError<E>>

Stops the container. Also removes it if remove is true.

Auto Trait Implementations§

§

impl<F, E> Freeze for Container<F, E>
where F: Freeze,

§

impl<F, E> RefUnwindSafe for Container<F, E>
where F: RefUnwindSafe,

§

impl<F, E> Send for Container<F, E>
where F: Send,

§

impl<F, E> Sync for Container<F, E>
where F: Sync,

§

impl<F, E> Unpin for Container<F, E>
where F: Unpin,

§

impl<F, E> UnwindSafe for Container<F, E>
where F: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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