pub struct TableBuilder { /* private fields */ }
Expand description
Builder Pattern for creating a new Table
Implementations§
Source§impl TableBuilder
impl TableBuilder
Sourcepub fn name(self, name: String) -> Self
pub fn name(self, name: String) -> Self
Sets the Name of the Table
use persistent_keystore_rs::Table;
let table = Table::new()
.name("MyTable".to_string());
Sourcepub fn primary_field(self, priary_key: FieldType) -> Result<Self, DatabaseError>
pub fn primary_field(self, priary_key: FieldType) -> Result<Self, DatabaseError>
Sets the FieldType of the primary_field
use persistent_keystore_rs::{Table, FieldType};
let table = Table::new()
.primary_field(FieldType::String).unwrap();
Sourcepub fn add_field(
self,
key: String,
field_type: FieldType,
) -> Result<Self, DatabaseError>
pub fn add_field( self, key: String, field_type: FieldType, ) -> Result<Self, DatabaseError>
Add a required field of FieldType and name to the Table
use persistent_keystore_rs::{Table, FieldType};
let table = Table::new()
.add_field("Count".to_string(), FieldType::I64).unwrap();
Sourcepub fn add_optional_field(
self,
key: String,
field_type: FieldType,
) -> Result<Self, DatabaseError>
pub fn add_optional_field( self, key: String, field_type: FieldType, ) -> Result<Self, DatabaseError>
Add an optional field of FieldType and name to the Table
use persistent_keystore_rs::{Table, FieldType};
let table = Table::new()
.add_optional_field("Notes".to_string(), FieldType::String).unwrap();
Sourcepub fn add_expiration(self, expire_after: Duration) -> Self
pub fn add_expiration(self, expire_after: Duration) -> Self
Add an expiration Duration to the Table. The timer for the expiration is set to the last time an Entry was updated.
Note that this does not happen automatically within this struct; but is utilized within Client
use persistent_keystore_rs::{Table, FieldType};
use std::time::Duration;
let table = Table::new()
.add_expiration(Duration::from_secs(60));
Sourcepub fn build(self) -> Result<Table, DatabaseError>
pub fn build(self) -> Result<Table, DatabaseError>
Validates the Table is properly configured and returns the Table object.
use persistent_keystore_rs::{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();
Auto Trait Implementations§
impl Freeze for TableBuilder
impl RefUnwindSafe for TableBuilder
impl Send for TableBuilder
impl Sync for TableBuilder
impl Unpin for TableBuilder
impl UnwindSafe for TableBuilder
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