pub struct PublicConfig { /* private fields */ }Expand description
The effective configuration with every secret-reference field removed.
Entries are held in byte order of their dotted paths. Serialises as a
JSON object whose first key is schema_version, followed by each dotted
path mapped to its value, so a client can recompute
PublicConfig::hash from the JSON alone.
§Examples
use stratum_node_config::{schema, ConfigDocument, Value};
let doc = ConfigDocument::parse(&schema().seed_text())?;
let public = doc.public_config();
assert_eq!(public.get("listen.address"), Some(&Value::from("127.0.0.1:7460")));
assert_eq!(public.get("secrets.pod_admin_key_ref"), None);Implementations§
Source§impl PublicConfig
impl PublicConfig
Sourcepub fn get(&self, path: &str) -> Option<&Value>
pub fn get(&self, path: &str) -> Option<&Value>
Returns the value at a dotted path, or None for secret-reference
fields and paths not in the schema.
Sourcepub fn iter(&self) -> PublicIter<'_> ⓘ
pub fn iter(&self) -> PublicIter<'_> ⓘ
Iterates over (path, value) pairs in byte order of the path.
Sourcepub fn canonical_text(&self) -> String
pub fn canonical_text(&self) -> String
Returns the canonical TOML text the hash is computed over.
The text is valid TOML. Its first line is
schema_version = <SCHEMA_VERSION>. Every public field follows, one
per line, as <dotted.path> = <value>\n, in byte order of the path.
Values use a fixed encoding that does not depend on any TOML library:
booleans are true/false; integers are decimal with a leading -
when negative; strings are double-quoted with " and \
backslash-escaped and every ASCII control character written as
\uXXXX in upper-case hex, all other characters as literal UTF-8;
lists are [, the encoded strings separated by ", ", then ].
Because no encoded value contains a raw newline and every string is
delimited and escaped, distinct configurations give distinct texts.
§Examples
use stratum_node_config::{schema, ConfigDocument};
let doc = ConfigDocument::parse(&schema().seed_text())?;
let text = doc.public_config().canonical_text();
assert!(text.starts_with("schema_version = 1\nbackup.age_recipients = []\n"));Sourcepub fn hash(&self) -> PublicHash
pub fn hash(&self) -> PublicHash
Returns the public-configuration hash.
The hash is SHA-256("stratum.public-config.v1\n" ‖ canonical_text),
where the prefix carries PUBLIC_HASH_VERSION and canonical_text
is PublicConfig::canonical_text encoded as UTF-8. Changing a
secret reference never changes it; changing any other field’s
effective value, the schema version, or a default that a document
relies on always does.
Trait Implementations§
Source§impl Clone for PublicConfig
impl Clone for PublicConfig
Source§impl Debug for PublicConfig
impl Debug for PublicConfig
impl Eq for PublicConfig
Source§impl<'a> IntoIterator for &'a PublicConfig
impl<'a> IntoIterator for &'a PublicConfig
Source§impl PartialEq for PublicConfig
impl PartialEq for PublicConfig
Source§impl Serialize for PublicConfig
impl Serialize for PublicConfig
impl StructuralPartialEq for PublicConfig
Auto Trait Implementations§
impl Forget for PublicConfig
impl Freeze for PublicConfig
impl Move for PublicConfig
impl RefUnwindSafe for PublicConfig
impl Send for PublicConfig
impl Sync for PublicConfigwhere
RawVecInner: Sync,
impl Unpin for PublicConfig
impl UnsafeUnpin for PublicConfig
impl UnwindSafe for PublicConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.