backhopper_core/model/
schema_files.rs1use std::collections::BTreeSet;
8use std::fmt;
9
10use serde::{Deserialize, Serialize};
11
12use crate::model::names::{ApplicationName, ConfKey, PartialName, RelativePath, ValidatorName};
13
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16pub struct SchemaFile {
17 pub path: RelativePath,
18 pub app: ApplicationName,
19 pub mappings: BTreeSet<ConfKey>,
20 pub validators: BTreeSet<ValidatorName>,
21}
22
23#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub struct PartialFile {
27 pub path: RelativePath,
28 pub app: ApplicationName,
29 pub name: PartialName,
30 pub mappings: BTreeSet<ConfKey>,
31 pub validators: BTreeSet<ValidatorName>,
32}
33
34#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
36pub struct PartialRef {
37 pub app: ApplicationName,
38 pub name: PartialName,
39}
40
41impl PartialFile {
42 #[must_use]
43 pub fn partial_ref(&self) -> PartialRef {
44 PartialRef {
45 app: self.app.clone(),
46 name: self.name.clone(),
47 }
48 }
49}
50
51impl fmt::Display for PartialRef {
52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53 write!(f, "{{{}, \"{}\"}}", self.app, self.name)
54 }
55}