[−][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_row(vec![ Entry::new_string("word", "cocina"), Entry::new_string("translation", "cuisine"), Entry::new_string("translation", "kitchen"), ]); let row_2 = db.add_row(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.find_row_ids_by_predicate(&vec![Predicate::new_equal_string("word", "coche")], None); assert_eq!(row_ids, [row_2]); let entries = db.entries_from_row_ids(&row_ids, &["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)
DbI32(i32)
DbDateTime(NaiveDateTime)
Methods
impl Data
[src]
pub fn now() -> Data
[src]
Returns new DbDateTime with current time as timestamp
pub fn date(&self) -> Option<String>
[src]
Trait Implementations
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 PartialEq<Data> for Data
[src]
impl Eq for Data
[src]
impl Debug for Data
[src]
impl Display for Data
[src]
impl Hash for Data
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
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 Unpin for Data
impl Sync for Data
impl Send for Data
impl UnwindSafe for Data
impl RefUnwindSafe for Data
Blanket Implementations
impl<T> From<T> for T
[src]
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, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,