use std::collections::BTreeSet;
use std::fmt;
use serde::{Deserialize, Serialize};
use crate::model::names::{ApplicationName, ConfKey, PartialName, RelativePath, ValidatorName};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SchemaFile {
pub path: RelativePath,
pub app: ApplicationName,
pub mappings: BTreeSet<ConfKey>,
pub validators: BTreeSet<ValidatorName>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PartialFile {
pub path: RelativePath,
pub app: ApplicationName,
pub name: PartialName,
pub mappings: BTreeSet<ConfKey>,
pub validators: BTreeSet<ValidatorName>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
pub struct PartialRef {
pub app: ApplicationName,
pub name: PartialName,
}
impl PartialFile {
#[must_use]
pub fn partial_ref(&self) -> PartialRef {
PartialRef {
app: self.app.clone(),
name: self.name.clone(),
}
}
}
impl fmt::Display for PartialRef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{{{}, \"{}\"}}", self.app, self.name)
}
}