pub struct TableBuilder<T> { /* private fields */ }Expand description
A builder that creates new tables and opens existing tables.
The default TableBuilder configures the table to ignore write back
automatically, ignore non json files, and report errors when
deserialization cant be completed
Implementations§
Source§impl<T> TableBuilder<T>
impl<T> TableBuilder<T>
Sourcepub fn set_manual_write(self) -> Self
pub fn set_manual_write(self) -> Self
Set the writeback to be manual
Sourcepub fn set_auto_write(self) -> Self
pub fn set_auto_write(self) -> Self
Set the writeback to be automatic on drops
Sourcepub fn set_read_only(self) -> Self
pub fn set_read_only(self) -> Self
Set the table so that it won’t be written over
Sourcepub fn set_read_non_json_is_error(self) -> Self
pub fn set_read_non_json_is_error(self) -> Self
Set the table so that non json files in the table’s directory provoke an error on loading
Sourcepub fn set_ignore_de_errors(self) -> Self
pub fn set_ignore_de_errors(self) -> Self
When a read file does not contain a valid json for the type T just ignore it
Sourcepub fn load(self) -> Result<Table<T>, TableError>where
T: Serialize + DeserializeOwned,
pub fn load(self) -> Result<Table<T>, TableError>where
T: Serialize + DeserializeOwned,
Load an existing table
§Errors
- Whenever there’s a file in the directory which you don’t have permission to read, or is not a file or directory
- Couldn’t open a file with the required permissions
- There is a deserialization error and the policy was
PromoteSerdeErrors - There was a non .json file in a table with the
OnlyJsonFilesextension policy
Sourcepub fn build(self) -> Result<Table<T>, TableBuilderError>where
T: Serialize + DeserializeOwned,
pub fn build(self) -> Result<Table<T>, TableBuilderError>where
T: Serialize + DeserializeOwned,
Create a new table. In order to do so a write policy must be in place
§Errors
- There was already a table in that directory
- Couldn’t create a path to the table
Trait Implementations§
Source§impl<T: Debug> Debug for TableBuilder<T>
impl<T: Debug> Debug for TableBuilder<T>
Auto Trait Implementations§
impl<T> Freeze for TableBuilder<T>
impl<T> RefUnwindSafe for TableBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for TableBuilder<T>where
T: Send,
impl<T> Sync for TableBuilder<T>where
T: Sync,
impl<T> Unpin for TableBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for TableBuilder<T>where
T: UnwindSafe,
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