pub trait ConfigSerializable {
// Required methods
fn to_json(&self) -> Result<String>;
fn from_json(json: &str) -> Result<Self>
where Self: Sized;
// Provided methods
fn save_to_file(&self, path: &Path) -> Result<()> { ... }
fn load_from_file(path: &Path) -> Result<Self>
where Self: Sized { ... }
}Expand description
Trait for objects that can be serialized as configuration
Required Methods§
Provided Methods§
Sourcefn save_to_file(&self, path: &Path) -> Result<()>
fn save_to_file(&self, path: &Path) -> Result<()>
Save to file
Sourcefn load_from_file(path: &Path) -> Result<Self>where
Self: Sized,
fn load_from_file(path: &Path) -> Result<Self>where
Self: Sized,
Load from file
Implementors§
impl<T> ConfigSerializable for Twhere
T: Serialize + for<'de> Deserialize<'de>,
Default implementation for types that implement Serialize + DeserializeOwned