pub trait Serializable {
// Required methods
fn state_dict(&self) -> StateDict;
fn load_state_dict(&mut self, state_dict: &StateDict) -> Result<()>;
// Provided methods
fn save<P: AsRef<Path>>(&self, path: P) -> Result<()> { ... }
fn load<P: AsRef<Path>>(&mut self, path: P) -> Result<()> { ... }
}Expand description
Trait for models that can be serialized
Required Methods§
Sourcefn state_dict(&self) -> StateDict
fn state_dict(&self) -> StateDict
Get state dictionary
Sourcefn load_state_dict(&mut self, state_dict: &StateDict) -> Result<()>
fn load_state_dict(&mut self, state_dict: &StateDict) -> Result<()>
Load state dictionary
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.