pub trait ReadWrite: Serialize + DeserializeOwned {
// Required method
fn create_null() -> Self;
// Provided methods
fn save_as<T: AsRef<str>>(&self, file_path: T) -> Result<(), LadduError> { ... }
fn load_from<T: AsRef<str>>(file_path: T) -> Result<Self, LadduError> { ... }
}
Expand description
A trait which allows structs with Serialize
and Deserialize
to be
written and read from files with a certain set of types/extensions.
Currently, Python’s pickle format is supported supported, since it’s an easy-to-parse standard that supports floating point values better that JSON or TOML
Required Methods§
Sourcefn create_null() -> Self
fn create_null() -> Self
Create a null version of the object which acts as a shell into which Python’s pickle
module
can load data. This generally shouldn’t be used to construct the struct in regular code.
Provided Methods§
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.