use crate::container::{Backend, BackendError, ExecOptions, ServiceStatus};
use async_trait::async_trait;
#[derive(Debug, Default, Clone, Copy)]
pub struct NullBackend;
#[async_trait]
impl Backend for NullBackend {
fn name(&self) -> &'static str {
"none"
}
async fn status(&self, _service: &str) -> Result<ServiceStatus, BackendError> {
Ok(ServiceStatus::Missing)
}
async fn exec(
&self,
service: &str,
_argv: &[&str],
_opts: &ExecOptions,
) -> Result<i32, BackendError> {
Err(BackendError::Reported(format!(
"backend = \"none\"; cannot exec in service `{service}` — set runtime.backend = \"compose\" to enable container exec"
)))
}
async fn passthrough(&self, _args: &[&str]) -> Result<i32, BackendError> {
Err(BackendError::Reported(
"backend = \"none\"; container passthrough is unavailable".into(),
))
}
async fn tail_logs(&self, _service: &str) -> Result<tokio::process::Child, BackendError> {
Err(BackendError::Reported(
"backend = \"none\"; declare a service in [[ui.pane]] only after setting runtime.backend = \"compose\""
.into(),
))
}
async fn service_action(
&self,
_action: &str,
_services: &[&str],
) -> Result<tokio::process::Child, BackendError> {
Err(BackendError::Reported(
"backend = \"none\"; set runtime.backend = \"compose\" to start / stop services".into(),
))
}
}