Skip to main content

shep_core/config/flockfile/
declared_app.rs

1//! [`DeclaredApp`]: one app as the document wrote it, keys and all.
2//!
3//! `#[serde(default)]` erases which keys a document named, so the key sets
4//! here are the only record of what it actually declared.
5
6use std::collections::BTreeSet;
7
8use serde::{Deserialize, Serialize};
9
10use crate::config::AppConfig;
11
12/// One app as the document declared it: the validated config, plus the
13/// keys the document literally wrote.
14///
15/// The key set cannot be recovered from [`AppConfig`] afterwards:
16/// `#[serde(default)]` gives every field a value, so a document naming
17/// four keys deserializes identically to one naming forty.
18/// [`Flockfile::parse_declared`](crate::config::flockfile::Flockfile::parse_declared) carries the claim out for a later merge
19/// that keys on what a template declares, not on its values.
20///
21/// `Serialize`/`Deserialize` since this type travels inside a wire
22/// request, keyed on the same claim. Derived `Debug` is safe: `config`
23/// redacts its own `env`, and `declared_env` holds only key names.
24#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
25pub struct DeclaredApp {
26    /// The app, validated the same way [`Flockfile::parse`](crate::config::flockfile::Flockfile::parse) validates one
27    pub config: AppConfig,
28    /// Top-level keys this app's table wrote, whatever their values
29    pub declared: BTreeSet<String>,
30    /// Keys inside this app's `env` table. Empty when `env` was not declared.
31    pub declared_env: BTreeSet<String>,
32}