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.

The field is reserved: a Stratum node generates its pod administration key itself and does not read this reference.

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.

Source

pub fn max_tenants(&self) -> u32

Returns membership.max_tenants, in 1..=10000.

Source

pub fn invitations_enabled(&self) -> bool

Returns membership.invitations_enabled.

Source

pub fn invitation_ttl_secs(&self) -> u32

Returns membership.invitation_ttl_secs, in 60..=2592000.

Source

pub fn max_pod_body_bytes(&self) -> u32

Returns limits.max_pod_body_bytes, in 1024..=1073741824.

Source

pub fn admission_requests_per_minute(&self) -> u32

Returns limits.admission_requests_per_minute, in 1..=6000.

Source

pub fn min_pod_free_bytes(&self) -> u64

Returns limits.min_pod_free_bytes; zero means the check is off.

Source

pub fn removal_grace_days(&self) -> u32

Returns membership.removal_grace_days, in 0..=3650.

The node stores the earliest purge time when a member is removed or cancelled, from the value in force then, and never allows less than 120 seconds.

§Examples
use stratum_node_config::{schema, ConfigDocument};

let doc = ConfigDocument::parse(&schema().seed_text())?;
let config = doc.config();
assert_eq!(config.removal_grace_days(), 30);
assert_eq!(config.removal_grace().as_secs(), 30 * 86_400);
Source

pub fn removal_grace(&self) -> Duration

Returns membership.removal_grace_days as a duration of whole days. Zero days is a zero duration; the 120 second floor is the node’s to apply.

§Examples
use stratum_node_config::{preview, schema, Change};

let doc = preview(&schema().seed_text(), &[Change::new("membership.removal_grace_days", 0)])?
    .into_document()
    .ok_or("the edit is valid")?;
assert!(doc.config().removal_grace().is_zero());
Source

pub fn pod_bytes_per_tenant(&self) -> u64

Returns limits.pod_bytes_per_tenant; zero means no limit.

§Examples
use stratum_node_config::{schema, ConfigDocument};

let doc = ConfigDocument::parse(&schema().seed_text())?;
assert_eq!(doc.config().pod_bytes_per_tenant(), 10 * 1024 * 1024 * 1024);
Source

pub fn is_over_quota(&self, pod_bytes: u64) -> bool

Returns true when a pod of pod_bytes bytes is over quota: the limit is above zero and pod_bytes is strictly above it.

This is the one definition of “over quota”; the controller decides the flag it publishes with it.

§Examples
use stratum_node_config::{preview, schema, Change};

let limited = preview(&schema().seed_text(), &[Change::new("limits.pod_bytes_per_tenant", 100)])?
    .into_document()
    .ok_or("the edit is valid")?;
assert!(!limited.config().is_over_quota(100));
assert!(limited.config().is_over_quota(101));

let unlimited = preview(&schema().seed_text(), &[Change::new("limits.pod_bytes_per_tenant", 0)])?
    .into_document()
    .ok_or("the edit is valid")?;
assert!(!unlimited.config().is_over_quota(u64::MAX));

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.