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.

§Errors

Returns ConfigCoreError when the requested configuration key is not registered.

Source

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

Validates that keys are non-empty and unique.

§Errors

Returns ConfigCoreError when registry keys are empty or duplicated.

Source

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

Validates that all categories belong to allowed_categories.

§Errors

Returns ConfigCoreError when a definition category violates registry constraints.

Source

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

Validates only the structural storage shape for a known key.

This does not run the product normalizer or dependency validator. A structurally valid value can still violate product rules. Use Self::normalize_value or Self::value_to_storage_for_key for the full validation pipeline before persistence.

§Errors

Returns ConfigCoreError when the key is unknown or the storage shape is invalid.

Source

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

Validates and normalizes a logical value for a known key.

Runs, in order: key lookup, input structure validation, the optional product normalizer, normalized output structure validation, and the optional dependency validator. The dependency validator receives the normalized value and the caller-supplied lookup.

The input must use the definition’s logical storage shape, for example a JSON string array for string_array. For encrypted secrets, validate plaintext here before the product encodes its storage envelope; do not normalize ciphertext as plaintext. This method has no persistence, snapshot, audit, or notification side effects.

§Errors

Returns ConfigCoreError when the key is unknown, either structure check fails, or the product normalizer or dependency validator rejects the value. Later stages do not run after a failure.

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.

Converts according to the registered type, then runs Self::normalize_value. Secret encoding, persistence, audit, snapshot updates, and notification remain caller-owned.

§Errors

Returns ConfigCoreError when the key is unknown, conversion or structure validation fails, or the normalizer or dependency validator rejects the value.

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 validation, visibility, permissions, and persistence policy to the product crate. For registered keys the order is type conversion, input structure validation, normalizer, output structure validation, then dependency validation. Secret encoding must follow this pipeline; this method does not persist values or update runtime state.

§Errors

Returns ConfigCoreError when conversion or structure validation fails, or a registered key’s normalizer or dependency validator rejects the value. Unknown keys use the custom scalar-string path rather than returning an unknown-key error.

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.

§Errors

Returns ConfigCoreError when a default fails structure validation, normalization, or dependency validation.

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