pub struct Settings { /* private fields */ }Expand description
A free-standing cpdb settings collection.
Settings are key/value pairs that can be serialised, persisted, and
later applied. For per-printer settings see [crate::Printer].
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn add_setting(&mut self, key: &str, value: &str) -> Result<()>
pub fn add_setting(&mut self, key: &str, value: &str) -> Result<()>
Inserts or overwrites a setting.
Sourcepub fn clear_setting(&mut self, key: &str) -> Result<bool>
pub fn clear_setting(&mut self, key: &str) -> Result<bool>
Removes a setting.
Returns Ok(true) when the key existed before this call.
Sourcepub fn save_to_disk(&self) -> Result<()>
pub fn save_to_disk(&self) -> Result<()>
Persists this settings collection to the cpdb-managed config dir.
The path is chosen by cpdb-libs (see cpdbGetUserConfDir) — callers
cannot override it.
Sourcepub fn read_from_disk() -> Result<Self>
pub fn read_from_disk() -> Result<Self>
Loads settings previously written via Settings::save_to_disk.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Settings
impl RefUnwindSafe for Settings
impl Unpin for Settings
impl UnsafeUnpin for Settings
impl UnwindSafe for Settings
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