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.
Sourcepub fn validate_unique_keys(&self) -> Result<()>
pub fn validate_unique_keys(&self) -> Result<()>
Validates that keys are non-empty and unique.
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.
Sourcepub fn validate_value(&self, key: &str, value: &str) -> Result<()>
pub fn validate_value(&self, key: &str, value: &str) -> Result<()>
Validates a storage string for a known key.
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>
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.
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.
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
visibility, permissions, and persistence policy to the product crate.
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.
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