Trait Filable

Source
pub trait Filable {
    type Unfiled;

    // Required methods
    fn load<P: AsRef<Path>>(&mut self, dir: P) -> Result<bool, String>;
    fn unload(&mut self, odir: Option<&Path>) -> Result<Self::Unfiled, String>;

    // Provided method
    fn unwrap(self) -> Result<Self::Unfiled, String>
       where Self: Sized { ... }
}
Expand description

Properties of a type containing a variable data structure partially stored by means of several serialization files

Required Associated Types§

Source

type Unfiled

Type of the unfiled data type

Required Methods§

Source

fn load<P: AsRef<Path>>(&mut self, dir: P) -> Result<bool, String>

Load all missing data from files; bool indicates if already loaded (false) or not

  • dir: P : directory path from which is loaded the serialized files of missing data
  • P: AsRef<Path> : type of the path
  • Output: a boolean or an error
Source

fn unload(&mut self, odir: Option<&Path>) -> Result<Self::Unfiled, String>

Optionally serialize all data on disk (filed data needs to be fully loaded) while unloading into the associated unfiled data type

  • odir: Option<&Path> : optional directory path where are saved the serialized files of all data; if None, nothing is saved
  • Output: unfiled data or error

Provided Methods§

Source

fn unwrap(self) -> Result<Self::Unfiled, String>
where Self: Sized,

Unload all data (filed data needs to be fully loaded) into the associated unfiled data type

  • Output: unfiled data or error

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§