TableBuilder

Struct TableBuilder 

Source
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>

Source

pub fn new<Q: AsRef<Path>>(dir: Q) -> Self

Create a new tableBuilder from a directory

§Panics
  • if dir can’t be converted into a string
Source

pub fn set_manual_write(self) -> Self

Set the writeback to be manual

Source

pub fn set_auto_write(self) -> Self

Set the writeback to be automatic on drops

Source

pub fn set_read_only(self) -> Self

Set the table so that it won’t be written over

Source

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

Source

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

Source

pub fn load(self) -> Result<Table<T>, TableError>

Load an existing table

§Errors
  1. Whenever there’s a file in the directory which you don’t have permission to read, or is not a file or directory
  2. Couldn’t open a file with the required permissions
  3. There is a deserialization error and the policy was PromoteSerdeErrors
  4. There was a non .json file in a table with the OnlyJsonFiles extension policy
Source

pub fn build(self) -> Result<Table<T>, TableBuilderError>

Create a new table. In order to do so a write policy must be in place

§Errors
  1. There was already a table in that directory
  2. Couldn’t create a path to the table

Trait Implementations§

Source§

impl<T: Debug> Debug for TableBuilder<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for TableBuilder<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.