pub trait ConfigWritable: Serialize {
// Required methods
fn save_path(&self) -> String;
fn save_folder(&self) -> String;
// Provided methods
fn as_json(&self, action: String) -> Result<String, EpochError> { ... }
fn save_with_context(
&self,
action_description: &str,
do_not_erase: &SaveMode,
) -> Result<(), EpochError> { ... }
}Expand description
Trait representing a serialisable / writable config
Required Methods§
Sourcefn save_folder(&self) -> String
fn save_folder(&self) -> String
The folder where to save the file to save the config
Provided Methods§
Sourcefn save_with_context(
&self,
action_description: &str,
do_not_erase: &SaveMode,
) -> Result<(), EpochError>
fn save_with_context( &self, action_description: &str, do_not_erase: &SaveMode, ) -> Result<(), EpochError>
Saves the config into its nominal path.
Existing subdirectories are not created.
If do_not_erase is SaveMode::Erase, an existing file is overwritten.
If do_not_erase is SaveMode::DoNotErase, an error is returned when the
file already exists.
§Arguments
action_description- A human-readable description used in error messages.do_not_erase- Determines whether to overwrite an existing file.
§Returns
Ok(())on success.Err(EpochError::ConfigWrite)on any serialization error.Err(EpochError::ConfigCreation)on any I/O 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.