use crate::error::Error;
use crate::model;
use crate::stdio::Stdio;
use crate::store::{Store, StoreError};
use std::os::fd::RawFd;
fn unsupported() -> Error {
Error::unavailable("use Containerization.framework", "it is macOS only")
}
pub struct Session {
store: Store,
}
impl Session {
pub fn new(store: Store) -> Self {
Self { store }
}
pub fn store(&self) -> &Store {
&self.store
}
pub fn boot(&self, _spec: &model::BootSpec) -> Result<(), Error> {
Err(unsupported())
}
pub fn exec(
&self,
_name: &str,
_id: &str,
_configuration: &model::LinuxProcessConfiguration,
_stdio: Stdio,
) -> Result<i32, Error> {
Err(unsupported())
}
pub fn resize(&self, _id: &str, _terminal: RawFd) -> Result<(), Error> {
Err(unsupported())
}
pub fn is_running(&self, _name: &str) -> bool {
false
}
pub fn is_unpacked(&self, _image: &str) -> Result<bool, Error> {
Err(unsupported())
}
pub fn images(&self) -> Result<Vec<String>, StoreError> {
self.store.images()
}
pub fn version() -> String {
format!(
"Containerization {}, kernel {}",
crate::INITFS_VERSION,
crate::KERNEL_VERSION
)
}
}
pub struct Builder {
store: Store,
}
impl Builder {
pub fn new(store: Store) -> Self {
Self { store }
}
pub fn store(&self) -> &Store {
&self.store
}
pub fn build(&self, _plan: &model::BuildPlan) -> Result<(), Error> {
Err(unsupported())
}
pub fn provision(&self) -> Result<(), Error> {
Err(unsupported())
}
}