pub struct Database {
pub sync_interval: Option<Duration>,
/* private fields */
}
Expand description
Database; a collection of Tables
Fields§
§sync_interval: Option<Duration>
Implementations§
Source§impl Database
impl Database
Sourcepub fn set_sync_duration(&mut self, duration: Duration)
pub fn set_sync_duration(&mut self, duration: Duration)
Sets the Sync Duration of the Database.
Note this is currently only utilized by the Client
use persistent_keystore_rs::Database;
use std::time::Duration;
let mut database = Database::default();
database.set_sync_duration(Duration::from_secs(60));
Sourcepub fn remove_sync_duration(&mut self)
pub fn remove_sync_duration(&mut self)
Removes the Sync Duration of the Database.
Note this is currently only utilized by the Client
use persistent_keystore_rs::Database;
let mut database = Database::default();
database.remove_sync_duration();
Sourcepub fn get_table(&mut self, table: &String) -> Result<&mut Table, DatabaseError>
pub fn get_table(&mut self, table: &String) -> Result<&mut Table, DatabaseError>
Returns a mutable reference to a Table within the Database
use persistent_keystore_rs::Database;
let mut database = Database::default();
let table = database.get_table(&"MyTable".to_string()).unwrap();
Sourcepub fn create_table(&mut self, table: Table) -> Result<(), DatabaseError>
pub fn create_table(&mut self, table: Table) -> Result<(), DatabaseError>
Creates a Table within the Database
use persistent_keystore_rs::{Database, Table, FieldType};
use std::time::Duration;
let table = Table::new()
.name("MyTable".to_string())
.primary_field(FieldType::String).unwrap()
.add_field("Count".to_string(), FieldType::I64).unwrap()
.add_optional_field("Notes".to_string(), FieldType::String).unwrap()
.add_expiration(Duration::from_secs(60))
.build().unwrap();
let mut database = Database::default();
database.create_table(table).unwrap();
Sourcepub fn drop_table(&mut self, table: &String) -> Result<(), DatabaseError>
pub fn drop_table(&mut self, table: &String) -> Result<(), DatabaseError>
Deletes the specified Table within the Database
use persistent_keystore_rs::Database;
let mut database = Database::default();
database.drop_table(&"MyTable".to_string()).unwrap();
Sourcepub fn list_tables(&mut self) -> Vec<String>
pub fn list_tables(&mut self) -> Vec<String>
Returns a Vec of Table names that are stored within the Database
use persistent_keystore_rs::Database;
let mut database = Database::default();
let tables = database.list_tables();
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Database
impl<'de> Deserialize<'de> for Database
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
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
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