pub struct SettingsManager { /* private fields */ }Expand description
Various settings used throughout Tycode. Each process has its own local settings that the user may update without impacting any other session (for example increase the maximum model cost for 1 session). Settings can also be saved and when saved, future processes will use the same settings.
Implementations§
Source§impl SettingsManager
impl SettingsManager
Sourcepub fn from_settings_dir(
settings_dir: PathBuf,
profile_name: Option<&str>,
) -> Result<Self>
pub fn from_settings_dir( settings_dir: PathBuf, profile_name: Option<&str>, ) -> Result<Self>
Create a settings manager from a specific settings directory and optional profile
Sourcepub fn update_setting<F>(&self, updater: F)
pub fn update_setting<F>(&self, updater: F)
Update in-memory settings with a closure. Note: settings are not saved to disk
Sourcepub fn save_settings(&self, settings: Settings) -> Result<()>
pub fn save_settings(&self, settings: Settings) -> Result<()>
Save provided settings
Sourcepub fn current_profile(&self) -> Option<&str>
pub fn current_profile(&self) -> Option<&str>
Get the current profile name if set
Sourcepub fn switch_profile(&mut self, name: &str) -> Result<()>
pub fn switch_profile(&mut self, name: &str) -> Result<()>
Switch to a different profile, loading its settings (creates if not exists)
Sourcepub fn save_as_profile(&self, name: &str) -> Result<()>
pub fn save_as_profile(&self, name: &str) -> Result<()>
Save current settings as a new profile file
Sourcepub fn list_profiles(&self) -> Result<Vec<String>>
pub fn list_profiles(&self) -> Result<Vec<String>>
List all available profile names
Sourcepub fn get_module_config<T: Default + DeserializeOwned>(
&self,
namespace: &str,
) -> T
pub fn get_module_config<T: Default + DeserializeOwned>( &self, namespace: &str, ) -> T
Get a module’s configuration, falling back to default if missing or unparseable.
pub fn set_module_config<T: Serialize>(&self, namespace: &str, value: T)
Trait Implementations§
Source§impl Clone for SettingsManager
impl Clone for SettingsManager
Source§fn clone(&self) -> SettingsManager
fn clone(&self) -> SettingsManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SettingsManager
impl RefUnwindSafe for SettingsManager
impl Send for SettingsManager
impl Sync for SettingsManager
impl Unpin for SettingsManager
impl UnwindSafe for SettingsManager
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
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>
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 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>
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 moreCreates a shared type from an unshared type.