use std::path::Path;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{Fidelity, Result};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct ArtifactFidelity {
pub path: String,
pub fidelity: Fidelity,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub loss: Vec<String>,
}
impl ArtifactFidelity {
pub fn byte(path: impl Into<String>) -> Self {
Self {
path: path.into(),
fidelity: Fidelity::ByteLossless,
loss: Vec::new(),
}
}
pub fn value(path: impl Into<String>) -> Self {
Self {
path: path.into(),
fidelity: Fidelity::ValueLossless,
loss: Vec::new(),
}
}
pub fn semantic(path: impl Into<String>, loss: Vec<String>) -> Self {
Self {
path: path.into(),
fidelity: Fidelity::Semantic,
loss,
}
}
}
pub trait OrchestrationCodec<W> {
fn compile(&self, home: &Path) -> Result<(W, Vec<ArtifactFidelity>)>;
fn decompile(&self, orchestration: &W, dest: &Path) -> Result<Vec<ArtifactFidelity>>;
}