pub struct JsonDB { /* private fields */ }
Expand description
Implementations§
Source§impl JsonDB
impl JsonDB
Sourcepub fn create_collection<S>(
self,
collection_path: S,
) -> Result<JsonDB, Box<dyn Error>>
pub fn create_collection<S>( self, collection_path: S, ) -> Result<JsonDB, Box<dyn Error>>
Creates a new collection either in your database or in another collection
§Examples
db.create_collection("your collection path")?;
Sourcepub fn write<J, S>(
self,
collection_path: S,
document: S,
data: J,
) -> Result<JsonDB, Box<dyn Error>>
pub fn write<J, S>( self, collection_path: S, document: S, data: J, ) -> Result<JsonDB, Box<dyn Error>>
Writes (or rewrites) data to document in collection
§Examples
db.write("your collection path", "your document", "struct that derives serde::serialize")?;
Sourcepub fn read<D, S>(
self,
collection_path: S,
document: S,
) -> Result<D, Box<dyn Error>>
pub fn read<D, S>( self, collection_path: S, document: S, ) -> Result<D, Box<dyn Error>>
Reads data from document in collection
let data: impl serde::Deserialize = db.read("your collection path", "your document")?;
Auto Trait Implementations§
impl Freeze for JsonDB
impl RefUnwindSafe for JsonDB
impl Send for JsonDB
impl Sync for JsonDB
impl Unpin for JsonDB
impl UnwindSafe for JsonDB
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