Skip to main content

crate_seq_ledger/
config.rs

1//! Top-level config struct mirroring `.crate-seq.toml` structure.
2
3use serde::{Deserialize, Serialize};
4
5use crate::LedgerEntry;
6
7/// Identity and registry target for the crate.
8#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
9#[serde(rename_all = "kebab-case")]
10pub struct CrateConfig {
11    /// Crate name as it appears in `Cargo.toml`.
12    pub name: String,
13    /// Registry alias (e.g. `"crates-io"`). Defaults to `crates.io` when absent.
14    #[serde(default)]
15    pub registry: Option<String>,
16}
17
18/// Behavioural knobs for the sequencer.
19#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
20#[serde(rename_all = "kebab-case")]
21pub struct LedgerSettings {
22    /// Version-discovery mode: `"git-tag"` or `"snapshot"`.
23    #[serde(default)]
24    pub mode: Option<String>,
25    /// Glob pattern used to match git tags for this crate.
26    #[serde(default)]
27    pub tag_pattern: Option<String>,
28    /// If `true`, the sequencer runs in dry-run mode by default.
29    #[serde(default)]
30    pub dry_run_default: Option<bool>,
31    /// Base delay in milliseconds for exponential backoff on registry calls.
32    #[serde(default)]
33    pub backoff_base_ms: Option<u64>,
34}
35
36/// Credentials configuration for registry authentication.
37#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
38#[serde(rename_all = "kebab-case")]
39pub struct LedgerAuth {
40    /// Name of the environment variable holding the registry token.
41    #[serde(default)]
42    pub token_env: Option<String>,
43    /// Shell command whose stdout is used as the registry token.
44    #[serde(default)]
45    pub token_cmd: Option<String>,
46}
47
48/// Root structure of a `.crate-seq.toml` file.
49#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
50#[serde(rename_all = "kebab-case")]
51pub struct CrateSeqLedger {
52    /// Crate identity and registry target.
53    #[serde(rename = "crate")]
54    pub crate_config: CrateConfig,
55    /// Behavioural knobs for the sequencer.
56    pub settings: LedgerSettings,
57    /// Registry authentication configuration.
58    pub auth: LedgerAuth,
59    /// All version entries tracked by this ledger.
60    #[serde(rename = "versions", default)]
61    pub entries: Vec<LedgerEntry>,
62}