Skip to main content

ConfigurationBus

Struct ConfigurationBus 

Source
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

Source

pub fn new() -> Self

Create a new configuration bus

Source

pub async fn set(&self, key: impl Into<String>, value: impl Into<ConfigValue>)

Set a configuration value

Notifies all subscribers of the change.

Source

pub async fn set_many(&self, values: HashMap<String, ConfigValue>)

Set multiple configuration values at once

Source

pub async fn get(&self, key: &str) -> Option<ConfigValue>

Get a configuration value

Source

pub async fn get_string(&self, key: &str) -> Option<String>

Get a string configuration value

Source

pub async fn get_integer(&self, key: &str) -> Option<i64>

Get an integer configuration value

Source

pub async fn get_float(&self, key: &str) -> Option<f64>

Get a float configuration value

Source

pub async fn get_boolean(&self, key: &str) -> Option<bool>

Get a boolean configuration value

Source

pub async fn get_or_default( &self, key: &str, default: ConfigValue, ) -> ConfigValue

Get a configuration value with default

Source

pub async fn delete(&self, key: &str) -> Option<ConfigValue>

Delete a configuration value

Returns the deleted value if it existed.

Source

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

Check if a configuration key exists

Source

pub async fn keys(&self) -> Vec<String>

List all configuration keys

Source

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.

Source

pub async fn get_with_prefix( &self, prefix: &str, ) -> HashMap<String, ConfigValue>

Get all configuration values matching a prefix

Source

pub fn subscribe(&self) -> Receiver<ConfigChangeEvent>

Subscribe to configuration changes

Returns a broadcast receiver that receives all configuration changes.

Source

pub async fn len(&self) -> usize

Get the total number of configuration entries

Source

pub async fn is_empty(&self) -> bool

Check if the configuration store is empty

Source

pub async fn clear(&self)

Clear all configuration values

Source

pub async fn dump(&self) -> HashMap<String, ConfigValue>

Dump all configuration as a HashMap

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ConfigurationBus

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

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

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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