pub struct DB<Struct: Serialize> { /* private fields */ }
Expand description
Main struct that handles the database
Implementations§
Source§impl<Struct: Serialize + Default + for<'de> Deserialize<'de>> DB<Struct>
impl<Struct: Serialize + Default + for<'de> Deserialize<'de>> DB<Struct>
Sourcepub fn new(location: String) -> Self
pub fn new(location: String) -> Self
Initializes the database
Examples found in repository?
More examples
examples/open.rs (line 9)
8fn main() {
9 let mut db: DB<Data> = DB::new("example".to_string());
10 db.populate(
11 "government".to_string(),
12 "id".to_string(),
13 Some(Data {
14 name: "".to_string(),
15 surname: "".to_string(),
16 }),
17 );
18 println!("{:#?}", db.open("government".to_string(), "id".to_string()));
19}
Sourcepub fn populate(&mut self, table: String, row: String, contents: Option<Struct>)
pub fn populate(&mut self, table: String, row: String, contents: Option<Struct>)
Populates the database with content
Examples found in repository?
More examples
examples/open.rs (lines 10-17)
8fn main() {
9 let mut db: DB<Data> = DB::new("example".to_string());
10 db.populate(
11 "government".to_string(),
12 "id".to_string(),
13 Some(Data {
14 name: "".to_string(),
15 surname: "".to_string(),
16 }),
17 );
18 println!("{:#?}", db.open("government".to_string(), "id".to_string()));
19}
Sourcepub fn open(self, table: String, row: String) -> Struct
pub fn open(self, table: String, row: String) -> Struct
Opens the database
Examples found in repository?
examples/open.rs (line 18)
8fn main() {
9 let mut db: DB<Data> = DB::new("example".to_string());
10 db.populate(
11 "government".to_string(),
12 "id".to_string(),
13 Some(Data {
14 name: "".to_string(),
15 surname: "".to_string(),
16 }),
17 );
18 println!("{:#?}", db.open("government".to_string(), "id".to_string()));
19}
Trait Implementations§
Source§impl<'de, Struct> Deserialize<'de> for DB<Struct>where
Struct: Deserialize<'de> + Serialize,
impl<'de, Struct> Deserialize<'de> for DB<Struct>where
Struct: Deserialize<'de> + Serialize,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<Struct> Freeze for DB<Struct>where
Struct: Freeze,
impl<Struct> RefUnwindSafe for DB<Struct>where
Struct: RefUnwindSafe,
impl<Struct> Send for DB<Struct>where
Struct: Send,
impl<Struct> Sync for DB<Struct>where
Struct: Sync,
impl<Struct> Unpin for DB<Struct>where
Struct: Unpin,
impl<Struct> UnwindSafe for DB<Struct>where
Struct: UnwindSafe,
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