use std::collections::BTreeMap;
use std::path::Path;
use std::time::Duration;
use async_trait::async_trait;
use futures::stream::BoxStream;
use crate::error::Result;
use crate::events::{EngineEvent, EventFilter};
use crate::logs::LogLine;
use crate::status::{ProjectStatus, ServiceStatus};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum Progress {
#[default]
Inherit,
Quiet,
}
#[derive(Clone, Debug, Default)]
pub struct UpOptions {
pub wait: bool,
pub wait_timeout: Option<Duration>,
pub env: BTreeMap<String, String>,
pub progress: Progress,
}
#[derive(Clone, Debug, Default)]
pub struct DownOptions {
pub volumes: bool,
pub env: BTreeMap<String, String>,
pub progress: Progress,
}
#[derive(Clone, Debug, Default)]
pub struct LogOptions {
pub follow: bool,
pub tail: Option<u32>,
pub services: Vec<String>,
}
pub type EngineStream<T> = BoxStream<'static, Result<T>>;
#[async_trait]
pub trait ComposeEngine: Send + Sync {
async fn up(&self, dir: &Path, opts: &UpOptions) -> Result<()>;
async fn down(&self, dir: &Path, opts: &DownOptions) -> Result<()>;
async fn ls(&self) -> Result<Vec<ProjectStatus>>;
async fn ps(&self, project: &str) -> Result<Vec<ServiceStatus>>;
async fn logs(&self, project: &str, opts: &LogOptions) -> Result<EngineStream<LogLine>>;
async fn events(&self, filter: &EventFilter) -> Result<EngineStream<EngineEvent>>;
async fn network_rm(&self, name: &str) -> Result<bool>;
}