Struct persistent_keystore_rs::Table [−][src]
pub struct Table {
pub name: String,
pub primary_field: FieldType,
pub fields: HashMap<String, FieldRequirement>,
pub expire_after: Option<Duration>,
// some fields omitted
}
Expand description
Table is a collection of Entry objects that meet a specified format criteria
Fields
name: String
primary_field: FieldType
fields: HashMap<String, FieldRequirement>
expire_after: Option<Duration>
Implementations
Returns a TableBuilder Instance that will be used to create a new table
use persistent_keystore_rs::Table;
let table = Table::new();
Returns a reference to an Entry within the Table matching the primary Field If the primary Field does not exist, DatabaseError::EntryDoesNotExists is returned.
use persistent_keystore_rs::Field;
let result = table.get(&Field::String("MyFirstEntry".to_string())).unwrap();
Inserts the provided entry into the Table If the primary Field exists, DatabaseError::EntryExists is returned.
use persistent_keystore_rs::{Entry, Field};
let entry = Entry::new()
.set_primary_field(Field::String("MyFirstEntry".to_string())).unwrap()
.add_field("TimeStamp".to_string(), Field::Date(SystemTime::now())).unwrap()
.build().unwrap();
table.insert(entry).unwrap();
Inserts the provided entry if it doesn’t exist, or updates if it does
use persistent_keystore_rs::{Entry, Field};
let entry = Entry::new()
.set_primary_field(Field::String("MyFirstEntry".to_string())).unwrap()
.add_field("TimeStamp".to_string(), Field::Date(SystemTime::now())).unwrap()
.build().unwrap();
table.insert_or_update(entry).unwrap();
let entry2 = Entry::new()
.set_primary_field(Field::String("MyFirstEntry".to_string())).unwrap()
.add_field("TimeStamp".to_string(), Field::Date(SystemTime::now())).unwrap()
.build().unwrap();
table.insert_or_update(entry2).unwrap();
Updates the provided entry within the Table. If the Entry does not exist, DatabaseError:EntryDoesNotExists is returned
use persistent_keystore_rs::{Entry, Field};
let entry = Entry::new()
.set_primary_field(Field::String("MyFirstEntry".to_string())).unwrap()
.add_field("TimeStamp".to_string(), Field::Date(SystemTime::now())).unwrap()
.build().unwrap();
table.update(entry).unwrap();
Deletes the entry with the associated primary_field from the Table. If the Entry does not exist, DatabaseError:EntryDoesNotExists is returned
use persistent_keystore_rs::Field;
table.delete(Field::String("MyFirstEntry".to_string())).unwrap();
Trait Implementations
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
Auto Trait Implementations
impl RefUnwindSafe for Table
impl UnwindSafe for Table
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more