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: Stringprimary_field: FieldTypefields: 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();

Returns all Entries from the Table

let results = table.scan().unwrap();

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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