Skip to main content

Config

Struct Config 

Source
pub struct Config { /* private fields */ }
Expand description

The effective configuration of a valid document, with one strongly typed getter per schema field.

Obtained from ConfigDocument::config. Every value has already passed validation, so the getters cannot fail.

§Examples

use stratum_node_config::{schema, ConfigDocument};

let doc = ConfigDocument::parse(&schema().seed_text())?;
let config = doc.config();
assert_eq!(config.listen_address().port(), 7460);
assert!(config.listen_address().ip().is_loopback());
assert_eq!(config.canonical_origin(), None);
assert_eq!(config.max_body_bytes(), 262_144);

Implementations§

Source§

impl Config

Source

pub fn node_name(&self) -> &str

Returns node.name.

Source

pub fn canonical_origin(&self) -> Option<&str>

Returns node.canonical_origin, or None while it is empty.

Source

pub fn listen_address(&self) -> SocketAddr

Returns listen.address, which is always a loopback address.

Source

pub fn state_dir(&self) -> &Path

Returns storage.state_dir, an absolute normalised path.

Source

pub fn backup_dir(&self) -> &Path

Returns storage.backup_dir, an absolute normalised path distinct from and not nested with Config::state_dir.

Source

pub fn age_recipients(&self) -> &[String]

Returns backup.age_recipients; each is a structurally valid age post-quantum hybrid recipient beginning with age1pq1.

Source

pub fn pod_admin_key_ref(&self) -> Option<&SecretRef>

Returns secrets.pod_admin_key_ref, or None while it is empty.

Source

pub fn federation_egress_enabled(&self) -> bool

Returns federation.egress_enabled.

Source

pub fn max_body_bytes(&self) -> u32

Returns limits.max_body_bytes, in 1024..=1048576.

Source

pub fn max_outstanding_challenges(&self) -> u32

Returns limits.max_outstanding_challenges, in 1..=64.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Config

Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Forget for Config

§

impl Freeze for Config

§

impl Move for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config
where RawVecInner: Send,

§

impl Sync for Config
where RawVecInner: Sync,

§

impl Unpin for Config
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Config

§

impl UnwindSafe for Config
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.