pub struct Store(/* private fields */);
Implementations§
Source§impl Store
impl Store
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self>
Opens a Store
against the specified path.
See new_with_cfg(..)
for more details
§Arguments
path
- path to the db directory of JSON documents
Sourcepub fn new_with_cfg<P: AsRef<Path>>(path: P, cfg: Config) -> Result<Self>
pub fn new_with_cfg<P: AsRef<Path>>(path: P, cfg: Config) -> Result<Self>
Opens a Store
against the specified path with the given configuration
If the Store
already exists, it will be opened, otherwise this has the side-effect of creating the new Store
and the backing directories and files.
§Arguments
path
- path to the db directory of JSON documents, if configured for single db mode then.json
will be used as the extension (replacing any existing extension)cfg
- configuration for the DB instance
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Returns the storage path for the backing JSON store.
In single-file-mode this will be the JSON file location, otherwise it’s the directory in which all JSON objects are stored.
pub fn save<T>(&self, obj: &T) -> Result<String>where
for<'de> T: Serialize + Deserialize<'de>,
pub fn save_with_id<T>(&self, obj: &T, id: &str) -> Result<String>where
for<'de> T: Serialize + Deserialize<'de>,
pub fn get<T>(&self, id: &str) -> Result<T>where
for<'de> T: Deserialize<'de>,
pub fn all<T>(&self) -> Result<BTreeMap<String, T>>where
for<'de> T: Deserialize<'de>,
pub fn delete(&self, id: &str) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl !RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl !UnwindSafe for Store
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