pub struct SubSettings<S: StorageBackend = JsonStorage> { /* private fields */ }Expand description
Sub-settings for per-entity configuration. Handler for a single sub-settings type
Implementations§
Source§impl<S: StorageBackend + Clone + 'static> SubSettings<S>
impl<S: StorageBackend + Clone + 'static> SubSettings<S>
Sourcepub fn new(
config_dir: &Path,
config: SubSettingsConfig,
storage: S,
credential_manager: Option<CredentialManager>,
) -> Result<Self>
pub fn new( config_dir: &Path, config: SubSettingsConfig, storage: S, credential_manager: Option<CredentialManager>, ) -> Result<Self>
Create a new SubSettings instance
§Arguments
config_dir- The directory where the configuration files are storedconfig- The configuration for the sub-settingsstorage- The storage backend to use
§Errors
Returns an error if:
- The cache strategy is invalid
- Profile migration fails
- File operations fail
pub fn root_path(&self) -> PathBuf
pub fn is_single_file(&self) -> bool
pub fn profiles_enabled(&self) -> bool
pub fn extension(&self) -> &str
pub fn schema_metadata(&self) -> Option<Arc<HashMap<String, SettingMetadata>>>
pub fn storage(&self) -> &S
pub fn invalidate_cache(&self)
Sourcepub fn profiles(&self) -> Result<&ProfileManager<S>>
pub fn profiles(&self) -> Result<&ProfileManager<S>>
Get the profile manager if enabled
§Errors
Returns an error if profiles are not enabled for this sub-settings type.
Sourcepub fn switch_profile(&self, name: &str) -> Result<()>
pub fn switch_profile(&self, name: &str) -> Result<()>
Sourcepub fn set_on_change<F>(&self, callback: F) -> Result<()>
pub fn set_on_change<F>(&self, callback: F) -> Result<()>
Sourcepub fn set_field<T: Serialize + Sync>(
&self,
name: &str,
field_path: &str,
value: &T,
) -> Result<()>
pub fn set_field<T: Serialize + Sync>( &self, name: &str, field_path: &str, value: &T, ) -> Result<()>
Update a single field in a sub-settings entry.
This performs a read-modify-write on one entry:
- Loads existing entry (or
{}if missing) - Sets the provided field path (supports dot notation)
- Saves through
set(), so schema validation and secret handling still apply
§Errors
Returns an error if serialization fails, schema validation fails, or store write fails.
Sourcepub fn get<T: DeserializeOwned>(&self, name: &str) -> Result<T>
pub fn get<T: DeserializeOwned>(&self, name: &str) -> Result<T>
Sourcepub fn get_all_values(&self) -> Result<HashMap<String, Value>>
pub fn get_all_values(&self) -> Result<HashMap<String, Value>>
Get all sub-setting entries as a map
Returns a HashMap<String, Value> with all entry names as keys
and their deserialized values. Entries that fail to load are silently skipped.
§Errors
Returns an error if the store cannot be read.
pub fn directory(&self) -> PathBuf
pub fn file_path(&self) -> Option<PathBuf>
Auto Trait Implementations§
impl<S = JsonStorage> !Freeze for SubSettings<S>
impl<S = JsonStorage> !RefUnwindSafe for SubSettings<S>
impl<S> Send for SubSettings<S>
impl<S> Sync for SubSettings<S>
impl<S> Unpin for SubSettings<S>where
S: Unpin,
impl<S> UnsafeUnpin for SubSettings<S>where
S: UnsafeUnpin,
impl<S = JsonStorage> !UnwindSafe for SubSettings<S>
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
Mutably borrows from an owned value. Read more