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
impl Entry
Sourcepub fn new_string(name: &str, value: &str) -> Entry
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}
Sourcepub fn compare(&self, predicate: &Predicate) -> bool
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);
pub fn compare_all(entries: &[Entry], predicate: &Predicate) -> bool
Sourcepub fn check_by_name(entries: &[Entry], name: &str) -> bool
pub fn check_by_name(entries: &[Entry], name: &str) -> bool
Return true if there is any entry with the given name
Sourcepub fn check_by_value(entries: &[Entry], name: &str, value: &Data) -> bool
pub fn check_by_value(entries: &[Entry], name: &str, value: &Data) -> bool
Return true if there is any entry with the given name
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entry
impl<'de> Deserialize<'de> for Entry
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
impl Eq for Entry
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> 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