pub struct PkvStore { /* private fields */ }
Expand description
Main resource for setting/getting values
Implementations§
source§impl PkvStore
impl PkvStore
sourcepub fn new(organization: &str, application: &str) -> Self
pub fn new(organization: &str, application: &str) -> Self
Creates or opens a persistent key value store
The given organization
and application
are used to create a backing file
in a corresponding location on the users device. Usually within the home or user folder
sourcepub fn new_with_qualifier(
qualifier: &str,
organization: &str,
application: &str
) -> Self
pub fn new_with_qualifier( qualifier: &str, organization: &str, application: &str ) -> Self
Creates or opens a persistent key value store
Like PkvStore::new
, but also provide a qualifier.
Some operating systems use the qualifier as part of the path to the store.
The qualifier is usually “com”, “org” etc.
sourcepub fn new_in_dir<P: AsRef<Path>>(path: P) -> Self
pub fn new_in_dir<P: AsRef<Path>>(path: P) -> Self
Creates or opens a persistent key value store
Like PkvStore::new
, but requires a direct path.
The path
is used to create a backing file
in a corresponding location on the users device.
sourcepub fn set<T: Serialize>(
&mut self,
key: impl AsRef<str>,
value: &T
) -> Result<(), SetError>
pub fn set<T: Serialize>( &mut self, key: impl AsRef<str>, value: &T ) -> Result<(), SetError>
Serialize and store the value
sourcepub fn set_string(
&mut self,
key: impl AsRef<str>,
value: &str
) -> Result<(), SetError>
pub fn set_string( &mut self, key: impl AsRef<str>, value: &str ) -> Result<(), SetError>
More or less the same as set::
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PkvStore
impl Send for PkvStore
impl Sync for PkvStore
impl Unpin for PkvStore
impl !UnwindSafe for PkvStore
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.