pub struct SettingsService { /* private fields */ }Expand description
Settings service - main interface for accessing and managing settings
Implementations§
Source§impl SettingsService
impl SettingsService
pub fn new( registry: Arc<FrozenSettingsRegistry>, meta: Arc<dyn MetaAdapter>, cache_size: usize, ) -> Self
Sourcepub async fn get(&self, tn_id: TnId, key: &str) -> ClResult<SettingValue>
pub async fn get(&self, tn_id: TnId, key: &str) -> ClResult<SettingValue>
Get setting value with full resolution (tenant -> global -> default)
Sourcepub async fn set<S: AsRef<str>>(
&self,
tn_id: TnId,
key: &str,
value: SettingValue,
roles: &[S],
) -> ClResult<Setting>
pub async fn set<S: AsRef<str>>( &self, tn_id: TnId, key: &str, value: SettingValue, roles: &[S], ) -> ClResult<Setting>
Set setting value with validation and permission checks
The roles parameter should be the authenticated user’s roles
Sourcepub async fn delete(&self, tn_id: TnId, key: &str) -> ClResult<bool>
pub async fn delete(&self, tn_id: TnId, key: &str) -> ClResult<bool>
Delete a setting (falls back to next level)
Sourcepub async fn validate_required_settings(&self) -> ClResult<()>
pub async fn validate_required_settings(&self) -> ClResult<()>
Validate that all required settings (no default and not optional) are configured
Sourcepub async fn get_string(&self, tn_id: TnId, key: &str) -> ClResult<String>
pub async fn get_string(&self, tn_id: TnId, key: &str) -> ClResult<String>
Type-safe getters (required - returns error if not found)
pub async fn get_int(&self, tn_id: TnId, key: &str) -> ClResult<i64>
pub async fn get_bool(&self, tn_id: TnId, key: &str) -> ClResult<bool>
pub async fn get_json(&self, tn_id: TnId, key: &str) -> ClResult<Value>
Sourcepub async fn get_string_opt(
&self,
tn_id: TnId,
key: &str,
) -> ClResult<Option<String>>
pub async fn get_string_opt( &self, tn_id: TnId, key: &str, ) -> ClResult<Option<String>>
Type-safe optional getters (returns None if not found or has no default) Still returns error if setting exists but has wrong type
pub async fn get_int_opt(&self, tn_id: TnId, key: &str) -> ClResult<Option<i64>>
pub async fn get_bool_opt( &self, tn_id: TnId, key: &str, ) -> ClResult<Option<bool>>
pub async fn get_json_opt( &self, tn_id: TnId, key: &str, ) -> ClResult<Option<Value>>
Sourcepub fn registry(&self) -> &Arc<FrozenSettingsRegistry>
pub fn registry(&self) -> &Arc<FrozenSettingsRegistry>
Get reference to registry (for listing all settings)
Sourcepub async fn list_by_prefix(
&self,
tn_id: TnId,
prefix: &str,
) -> ClResult<Vec<(String, SettingValue, &SettingDefinition)>>
pub async fn list_by_prefix( &self, tn_id: TnId, prefix: &str, ) -> ClResult<Vec<(String, SettingValue, &SettingDefinition)>>
List stored settings by prefix with definition metadata
This queries the database for actual stored settings matching the prefix, then resolves each against the registry (supporting wildcard patterns like “ui.*”). Global settings are merged with tenant-specific settings (tenant overrides global).
Auto Trait Implementations§
impl Freeze for SettingsService
impl !RefUnwindSafe for SettingsService
impl Send for SettingsService
impl Sync for SettingsService
impl Unpin for SettingsService
impl UnsafeUnpin for SettingsService
impl !UnwindSafe for SettingsService
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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