Type Definition koit::FileDatabase[][src]

type FileDatabase<D, F> = Database<D, File, F>;
This is supported on crate feature file-backend only.
Expand description

A file-backed database.

Note: this requires its futures to be executed on the Tokio 0.3 runtime.

Implementations

impl<D, F> FileDatabase<D, F> where
    F: Format<D>, 
[src]

pub async fn load_from_path<P>(path: P) -> Result<Self, KoitError> where
    P: AsRef<Path>, 
[src]

Construct the file-backed database from the given path. This attempts to load data from the given file.

Errors

If the file cannot be read, or the formatter cannot decode the data, an error variant will be returned.

pub async fn load_from_path_or_else<P, T>(
    path: P,
    factory: T
) -> Result<Self, KoitError> where
    P: AsRef<Path>,
    T: FnOnce() -> D, 
[src]

Construct the file-backed database from the given path. If the file does not exist, the file is created. Then factory is called and its return value is used as the initial value. This data is immediately and saved to file.

pub async fn load_from_path_or_default<P>(path: P) -> Result<Self, KoitError> where
    P: AsRef<Path>,
    D: Default
[src]

Same as load_from_path_or_else, except it uses Default instead of a factory.