Skip to main content

ConfigRegistry

Struct ConfigRegistry 

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

Static registry of product configuration definitions.

Implementations§

Source§

impl ConfigRegistry

Source

pub const fn new(definitions: &'static [ConfigDefinition]) -> Self

Creates a registry from a static definition slice.

Source

pub const fn definitions(&self) -> &'static [ConfigDefinition]

Returns all registered definitions.

Source

pub fn get(&self, key: &str) -> Option<&'static ConfigDefinition>

Returns the definition for key.

Source

pub fn contains_key(&self, key: &str) -> bool

Returns whether key is registered.

Source

pub fn require(&self, key: &str) -> Result<&'static ConfigDefinition>

Returns the definition for key or an unknown-key error.

Source

pub fn validate_unique_keys(&self) -> Result<()>

Validates that keys are non-empty and unique.

Source

pub fn validate_categories(&self, allowed_categories: &[&str]) -> Result<()>

Validates that all categories belong to allowed_categories.

Source

pub fn validate_value(&self, key: &str, value: &str) -> Result<()>

Validates a storage string for a known key.

Source

pub fn normalize_value( &self, lookup: &dyn ConfigValueLookup, key: &str, value: &str, ) -> Result<String>

Normalizes a storage string for a known key.

The input is expected to already match the structural storage shape for the definition’s value type, for example a JSON string array for string_array.

Source

pub fn value_to_normalized_storage( &self, lookup: &dyn ConfigValueLookup, key: &str, value: &ConfigValue, ) -> Result<String>

Converts an API-facing value into normalized storage for a known key.

Source

pub fn value_to_storage_for_key( &self, lookup: &dyn ConfigValueLookup, key: &str, value: &ConfigValue, ) -> Result<String>

Converts an API-facing value into storage for either a registered key or a custom key.

Registered keys use their declared ConfigValueType and run through the full registry normalization pipeline. Custom keys are treated as scalar strings by default, leaving their visibility, permissions, and persistence policy to the product crate.

Source

pub fn apply_definition(&self, config: StoredConfig) -> StoredConfig

Applies definition metadata to a system-owned stored row.

Source

pub fn default_seed_records(&self) -> Result<Vec<ConfigSeedRecord>>

Builds default seed rows from the registry.

Defaults are normalized in registry order. If a normalizer or dependency validator consults another config key, that dependency should appear earlier in the registry.

Trait Implementations§

Source§

impl Debug for ConfigRegistry

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more