Trait fastsim_core::traits::SerdeAPI
source · pub trait SerdeAPI: Serialize + for<'a> Deserialize<'a> {
// Provided methods
fn init(&mut self) -> Result<()> { ... }
fn to_file(&self, filename: &str) -> Result<(), Error> { ... }
fn from_file(filename: &str) -> Result<Self, Error>
where for<'de> Self: Sized + Deserialize<'de> { ... }
fn to_json(&self) -> String { ... }
fn from_json(json_str: &str) -> Result<Self, Error> { ... }
fn to_yaml(&self) -> String { ... }
fn from_yaml(yaml_str: &str) -> Result<Self, Error> { ... }
fn to_bincode(&self) -> Vec<u8> { ... }
fn from_bincode(encoded: &[u8]) -> Result<Self, Error> { ... }
}Provided Methods§
sourcefn from_file(filename: &str) -> Result<Self, Error>where
for<'de> Self: Sized + Deserialize<'de>,
fn from_file(filename: &str) -> Result<Self, Error>where for<'de> Self: Sized + Deserialize<'de>,
Read from file and return instantiated struct. Method adaptively calls deserialization methods dependent on the suffix of the file name given as str. Function returns a dynamic Error Result if it fails.
Argument:
filename: astrstoring the targeted file name. Currently.jsonand.yamlsuffixes are supported
Returns:
A Rust Result wrapping data structure if method is called successfully; otherwise a dynamic Error.
sourcefn to_bincode(&self) -> Vec<u8>
fn to_bincode(&self) -> Vec<u8>
bincode serialization method.
sourcefn from_bincode(encoded: &[u8]) -> Result<Self, Error>
fn from_bincode(encoded: &[u8]) -> Result<Self, Error>
bincode deserialization method.