use bollard::Docker;
use crate::{error::TestError, host_container::HostContainer};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Mode {
Standalone,
Containerized,
}
#[derive(Debug)]
pub struct Host {
container: Option<HostContainer>,
}
impl Host {
pub(crate) async fn current(docker: &Docker) -> Result<Self, TestError> {
Ok(Self {
container: HostContainer::current(docker).await?,
})
}
pub fn container(&self) -> Option<&HostContainer> {
self.container.as_ref()
}
pub fn mode(&self) -> Mode {
if self.container.is_none() {
Mode::Standalone
} else {
Mode::Containerized
}
}
}