[−][src]Enum vdb::Data
A basic database system to store key/value pairs with few dependencies.
Examples
use vdb::{Db, Entry, Predicate}; let mut db = Db::new("test-db"); let row_1 = db.add(vec![ Entry::new_string("word", "cocina"), Entry::new_string("translation", "cuisine"), Entry::new_string("translation", "kitchen"), ]); let row_2 = db.add(vec![ Entry::new_string("word", "coche"), Entry::new_string("translation", "car"), ]); // Load and save db.save(); let mut new_db = Db::load("test-db").unwrap(); let row_ids = new_db.find_all_row_ids(); assert_eq!(row_ids.len(), 2); // Find rows let row_ids = db.select_row_ids(&vec![Predicate::new_equal_string("word", "coche")], None); assert_eq!(row_ids, [row_2]); let entries = db.entries_from_row_ids(&row_ids, vec![String::from("translation")]); assert_eq!(entries[0][0], Entry::new_string("translation", "car")); // Delete let coche = db.find_first_row_id_by_value("word", &Db::db_string("coche")); assert_eq!(coche, Some(row_2)); db.delete_rows(&[row_1, row_2]); let no_coche = db.find_first_row_id_by_value("word", &Db::db_string("coche")); assert_eq!(no_coche, None);
Data types currently implemented in the database
Variants
DbString(String)DbInt(i32)DbDateTime(NaiveDateTime)Methods
impl Data[src]
Trait Implementations
impl PartialEq<Data> for Data[src]
impl Clone for Data[src]
fn clone(&self) -> Data[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Debug for Data[src]
impl Display for Data[src]
impl Serialize for Data[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl<'de> Deserialize<'de> for Data[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Sync for Data
impl Unpin for Data
impl Send for Data
impl UnwindSafe for Data
impl RefUnwindSafe for Data
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
T: Deserialize<'de>,