Struct DB

Source
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>

Source

pub fn new(location: String) -> Self

Initializes the database

Examples found in repository?
examples/create.rs (line 11)
9fn main() {
10    // Initialize the database
11    let mut db: DB<Data> = DB::new("database".to_string());
12    db.populate("id".to_string(), "personal".to_string(), None);
13}
More examples
Hide additional 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}
Source

pub fn populate(&mut self, table: String, row: String, contents: Option<Struct>)

Populates the database with content

Examples found in repository?
examples/create.rs (line 12)
9fn main() {
10    // Initialize the database
11    let mut db: DB<Data> = DB::new("database".to_string());
12    db.populate("id".to_string(), "personal".to_string(), None);
13}
More examples
Hide additional 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}
Source

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<Struct: Default + Serialize> Default for DB<Struct>

Source§

fn default() -> DB<Struct>

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Struct> Serialize for DB<Struct>
where Struct: Serialize + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,