Struct Entry

Source
pub struct Entry {
    pub name: String,
    pub value: Data,
}
Expand description

Each RowId has many entries. Comparable to column name+data in relational databases.

Fields§

§name: String§value: Data

Implementations§

Source§

impl Entry

Source

pub fn new_string(name: &str, value: &str) -> Entry

Shortcut for creating a new Entry with a DbString

Examples found in repository?
examples/notebook.rs (line 41)
23fn new_entry(db: &mut Db) {
24    println!("Enter title:");
25    print!("> ");
26    io::stdout().flush().unwrap();
27
28    let mut input = "".to_string();
29    let title = {
30        let _bytes_read = io::stdin().read_line(&mut input).unwrap();
31        input.trim()
32    };
33    if !title.is_empty() {
34        println!("Enter text:");
35        print!("> ");
36        io::stdout().flush().unwrap();
37        let mut input = "".to_string();
38        let _bytes_read = io::stdin().read_line(&mut input).unwrap();
39        let text = input.trim();
40        db.add_row(vec![
41            Entry::new_string("title", title),
42            Entry::new_string("text", text),
43        ]);
44    } else {
45        println!("Abort.");
46    }
47}
Source

pub fn new_i32(name: &str, value: i32) -> Entry

Shortcut for creating a new Entry with a DbI32

Source

pub fn compare(&self, predicate: &Predicate) -> bool

§Examples
use vdb::{Entry,Predicate};
let a = Entry::new_string("mundo", "world");

assert_eq!(a.compare(&Predicate::new_equal_string("mundo", "world")), true);
assert_eq!(a.compare(&Predicate::new_contains("mundo", "orl")), true);
assert_eq!(a.compare(&Predicate::new_equal_string("mundo", "World")), false);
Source

pub fn compare_all(entries: &[Entry], predicate: &Predicate) -> bool

Source

pub fn check_by_name(entries: &[Entry], name: &str) -> bool

Return true if there is any entry with the given name

Source

pub fn check_by_value(entries: &[Entry], name: &str, value: &Data) -> bool

Return true if there is any entry with the given name

Source

pub fn get_first_by_name(entries: &[Entry], name: &str) -> Option<Entry>

Return first Entry in a given list that matches name

Source

pub fn get_first_by_name_mut<'a>( entries: &'a mut Vec<Entry>, name: &str, ) -> Option<&'a mut Entry>

Return first Entry in a given list that matches name as mutable reference

Trait Implementations§

Source§

impl Clone for Entry

Source§

fn clone(&self) -> Entry

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Entry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Entry

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 Hash for Entry

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Entry

Source§

fn eq(&self, other: &Entry) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Entry

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

impl Eq for Entry

Source§

impl StructuralPartialEq for Entry

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl UnwindSafe for Entry

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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>,