pub trait SettingsManager {
    // Required methods
    fn load_file<T: DeserializeOwned>(
        &self,
        path: impl AsRef<Path>,
    ) -> Result<T>;
    fn save_file<T: Serialize>(
        &self,
        path: impl AsRef<Path>,
        data: &T,
        pretty: bool,
    ) -> Result<()>;
    fn settings_path(&self) -> Result<PathBuf>;
    fn global_record_path(&self, game: &str) -> Result<PathBuf>;
    fn records_path(
        &self,
        game: &str,
    ) -> Result<impl Iterator<Item = Result<PathBuf>>>;
    fn record_path(&self, game: &str, i: usize) -> Result<PathBuf>;
    // Provided methods
    fn load_settings(&self) -> Result<Settings> { ... }
    fn save_settings(&self, data: &Settings) -> Result<()> { ... }
    fn load_global_record(&self, game: &str) -> Result<GlobalRecord> { ... }
    fn save_global_record(&self, game: &str, data: &GlobalRecord) -> Result<()> { ... }
    fn load_records(&self, game: &str) -> Result<Vec<ActionRecord>> { ... }
    fn save_records(&self, game: &str, contexts: &[ActionRecord]) -> Result<()> { ... }
}Expand description
A settings manager trait.
This type should handle the file loading and saving, and manage the paths of the files.
Required Methods§
Sourcefn load_file<T: DeserializeOwned>(&self, path: impl AsRef<Path>) -> Result<T>
 
fn load_file<T: DeserializeOwned>(&self, path: impl AsRef<Path>) -> Result<T>
Load a file from specified path.
Sourcefn save_file<T: Serialize>(
    &self,
    path: impl AsRef<Path>,
    data: &T,
    pretty: bool,
) -> Result<()>
 
fn save_file<T: Serialize>( &self, path: impl AsRef<Path>, data: &T, pretty: bool, ) -> Result<()>
Save a file to specified path.
Sourcefn settings_path(&self) -> Result<PathBuf>
 
fn settings_path(&self) -> Result<PathBuf>
Get the settings path.
Sourcefn global_record_path(&self, game: &str) -> Result<PathBuf>
 
fn global_record_path(&self, game: &str) -> Result<PathBuf>
Get the global record path.
Provided Methods§
Sourcefn load_settings(&self) -> Result<Settings>
 
fn load_settings(&self) -> Result<Settings>
Load Settings.
Sourcefn load_global_record(&self, game: &str) -> Result<GlobalRecord>
 
fn load_global_record(&self, game: &str) -> Result<GlobalRecord>
Load GlobalRecord.
Sourcefn save_global_record(&self, game: &str, data: &GlobalRecord) -> Result<()>
 
fn save_global_record(&self, game: &str, data: &GlobalRecord) -> Result<()>
Save GlobalRecord.
Sourcefn load_records(&self, game: &str) -> Result<Vec<ActionRecord>>
 
fn load_records(&self, game: &str) -> Result<Vec<ActionRecord>>
Load all ActionRecord.
Sourcefn save_records(&self, game: &str, contexts: &[ActionRecord]) -> Result<()>
 
fn save_records(&self, game: &str, contexts: &[ActionRecord]) -> Result<()>
Save all ActionRecord.
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.