pub struct ConfigRegistry { /* private fields */ }Expand description
Static registry of product configuration definitions.
Implementations§
Source§impl ConfigRegistry
impl ConfigRegistry
Sourcepub const fn new(definitions: &'static [ConfigDefinition]) -> Self
pub const fn new(definitions: &'static [ConfigDefinition]) -> Self
Creates a registry from a static definition slice.
Sourcepub const fn definitions(&self) -> &'static [ConfigDefinition]
pub const fn definitions(&self) -> &'static [ConfigDefinition]
Returns all registered definitions.
Sourcepub fn get(&self, key: &str) -> Option<&'static ConfigDefinition>
pub fn get(&self, key: &str) -> Option<&'static ConfigDefinition>
Returns the definition for key.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns whether key is registered.
Sourcepub fn require(&self, key: &str) -> Result<&'static ConfigDefinition>
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.
Sourcepub fn validate_unique_keys(&self) -> Result<()>
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.
Sourcepub fn validate_categories(&self, allowed_categories: &[&str]) -> Result<()>
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.
Sourcepub fn validate_value_structure(&self, key: &str, value: &str) -> Result<()>
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.
Sourcepub fn normalize_value(
&self,
lookup: &dyn ConfigValueLookup,
key: &str,
value: &str,
) -> Result<String>
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.
Sourcepub fn value_to_normalized_storage(
&self,
lookup: &dyn ConfigValueLookup,
key: &str,
value: &ConfigValue,
) -> Result<String>
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.
Sourcepub fn value_to_storage_for_key(
&self,
lookup: &dyn ConfigValueLookup,
key: &str,
value: &ConfigValue,
) -> Result<String>
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.
Sourcepub fn apply_definition(&self, config: StoredConfig) -> StoredConfig
pub fn apply_definition(&self, config: StoredConfig) -> StoredConfig
Applies definition metadata to a system-owned stored row.
Sourcepub fn default_seed_records(&self) -> Result<Vec<ConfigSeedRecord>>
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§
Auto Trait Implementations§
impl Freeze for ConfigRegistry
impl RefUnwindSafe for ConfigRegistry
impl Send for ConfigRegistry
impl Sync for ConfigRegistry
impl Unpin for ConfigRegistry
impl UnsafeUnpin for ConfigRegistry
impl UnwindSafe for ConfigRegistry
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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