1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Schema, validation, comment-preserving editing and public hashing for a
//! Stratum node's `stratum.toml`.
//!
//! **Pre-release.** This is `0.1.0-alpha`: the API and the file format may
//! change before 0.1.0.
//!
//! # The model
//!
//! - **One schema table.** [`schema`] returns the only definition of the
//! configuration: every field's dotted path, [`ValueType`], default,
//! description and [`ApplyClass`]. Validation, the seed document, the
//! typed [`Config`], the public view and the serialised form served by an
//! HTTP schema endpoint are all derived from it, so they cannot drift.
//! - **Documents.** [`ConfigDocument::parse`] turns `stratum.toml` text into
//! a validated document or a list of every [`ValidationError`]: syntax,
//! unknown keys, wrong types, out-of-range values, field rules and
//! cross-field conflicts. A document carries `schema_version =
//! `[`SCHEMA_VERSION`]; any other version is rejected. Omitted fields take
//! their defaults.
//! - **Preview.** [`preview`] applies a list of [`Change`]s to base text and
//! reports, without side effects, the edited text (comments and order
//! kept), a unified diff, the changed fields in schema order with
//! secret references redacted, each change's apply class, the strictest
//! class overall, and every validation error of the result.
//! - **Apply classes.** [`ApplyClass::Live`] < [`ApplyClass::Restart`] <
//! [`ApplyClass::Redeploy`]; the strictest class of a set of changes is
//! their maximum and tells the caller what it must do for them to take
//! effect.
//! - **Public hash.** [`ConfigDocument::public_config`] is the effective
//! configuration minus secret-reference fields, and
//! [`ConfigDocument::public_hash`] is SHA-256 over its documented
//! canonical encoding ([`PublicConfig::canonical_text`]) prefixed with
//! [`PUBLIC_HASH_VERSION`]. Changing a secret reference leaves the hash
//! unchanged; changing anything else changes it.
//!
//! The crate is pure: it performs no filesystem, network, clock or
//! environment access and never resolves a secret reference. Text longer
//! than [`MAX_DOCUMENT_BYTES`] (256 KiB) is refused before it is parsed. A
//! syntax error reports only its line and column, never the parser's
//! description, which can quote the input.
//!
//! `backup.age_recipients` accepts only post-quantum hybrid age recipients
//! (`age1pq1…`), checked structurally (lowercase Bech32, checksum, padding,
//! key length) without depending on `age`. The list holds at most
//! [`MAX_BACKUP_RECIPIENTS`] (32) entries, the most a Stratum node encrypts a
//! backup to.
//!
//! # Examples
//!
//! ```
//! use stratum_node_config::{preview, schema, ApplyClass, Change, ConfigDocument};
//!
//! // Start from the generated seed, which validates and holds the defaults.
//! let seed = schema().seed_text();
//! let before = ConfigDocument::parse(&seed)?;
//!
//! // Preview an edit and inspect it before committing anything.
//! let p = preview(&seed, &[Change::new("node.name", "alpha")])?;
//! assert!(p.errors().is_empty());
//! assert_eq!(p.strictest_apply_class(), Some(ApplyClass::Live));
//!
//! let after = p.into_document().ok_or("edit should be valid")?;
//! assert_eq!(after.config().node_name(), "alpha");
//! assert_ne!(after.public_hash(), before.public_hash());
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Value;
/// Compiles and runs the README example as a doctest.
;