pub struct ConfigurationBus { /* private fields */ }Expand description
Shared configuration bus for cross-module configuration
Provides a thread-safe, async-friendly way for modules to share configuration without direct dependencies.
Implementations§
Source§impl ConfigurationBus
impl ConfigurationBus
Sourcepub async fn set(&self, key: impl Into<String>, value: impl Into<ConfigValue>)
pub async fn set(&self, key: impl Into<String>, value: impl Into<ConfigValue>)
Set a configuration value
Notifies all subscribers of the change.
Sourcepub async fn set_many(&self, values: HashMap<String, ConfigValue>)
pub async fn set_many(&self, values: HashMap<String, ConfigValue>)
Set multiple configuration values at once
Sourcepub async fn get(&self, key: &str) -> Option<ConfigValue>
pub async fn get(&self, key: &str) -> Option<ConfigValue>
Get a configuration value
Sourcepub async fn get_string(&self, key: &str) -> Option<String>
pub async fn get_string(&self, key: &str) -> Option<String>
Get a string configuration value
Sourcepub async fn get_integer(&self, key: &str) -> Option<i64>
pub async fn get_integer(&self, key: &str) -> Option<i64>
Get an integer configuration value
Sourcepub async fn get_boolean(&self, key: &str) -> Option<bool>
pub async fn get_boolean(&self, key: &str) -> Option<bool>
Get a boolean configuration value
Sourcepub async fn get_or_default(
&self,
key: &str,
default: ConfigValue,
) -> ConfigValue
pub async fn get_or_default( &self, key: &str, default: ConfigValue, ) -> ConfigValue
Get a configuration value with default
Sourcepub async fn delete(&self, key: &str) -> Option<ConfigValue>
pub async fn delete(&self, key: &str) -> Option<ConfigValue>
Delete a configuration value
Returns the deleted value if it existed.
Sourcepub async fn keys_with_prefix(&self, prefix: &str) -> Vec<String>
pub async fn keys_with_prefix(&self, prefix: &str) -> Vec<String>
List configuration keys matching a prefix
For example, keys_with_prefix("sapiens.") returns all sapiens configuration.
Sourcepub async fn get_with_prefix(
&self,
prefix: &str,
) -> HashMap<String, ConfigValue>
pub async fn get_with_prefix( &self, prefix: &str, ) -> HashMap<String, ConfigValue>
Get all configuration values matching a prefix
Sourcepub fn subscribe(&self) -> Receiver<ConfigChangeEvent>
pub fn subscribe(&self) -> Receiver<ConfigChangeEvent>
Subscribe to configuration changes
Returns a broadcast receiver that receives all configuration changes.
Sourcepub async fn dump(&self) -> HashMap<String, ConfigValue>
pub async fn dump(&self) -> HashMap<String, ConfigValue>
Dump all configuration as a HashMap
Sourcepub async fn load(&self, values: HashMap<String, ConfigValue>)
pub async fn load(&self, values: HashMap<String, ConfigValue>)
Load configuration from a HashMap
Merges with existing configuration (overwrites duplicates).
Trait Implementations§
Source§impl Clone for ConfigurationBus
impl Clone for ConfigurationBus
Auto Trait Implementations§
impl !RefUnwindSafe for ConfigurationBus
impl !UnwindSafe for ConfigurationBus
impl Freeze for ConfigurationBus
impl Send for ConfigurationBus
impl Sync for ConfigurationBus
impl Unpin for ConfigurationBus
impl UnsafeUnpin for ConfigurationBus
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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