pub trait Serialization: Sized {
// Required methods
fn save_to_json(&self) -> Value;
fn load_from_json(value: Value) -> Result<Self>;
// Provided methods
fn save_to_string(&self) -> String { ... }
fn load_from_str(string: &str) -> Result<Self> { ... }
}
Expand description
This trait is implemented by Game and can be used to serialize/deserialize Hex games to/from strings or JSON.
Required Methods§
Sourcefn save_to_json(&self) -> Value
fn save_to_json(&self) -> Value
Save this game as a Serde JSON value
Sourcefn load_from_json(value: Value) -> Result<Self>
fn load_from_json(value: Value) -> Result<Self>
Load a game from a Serde JSON value.
Provided Methods§
Sourcefn save_to_string(&self) -> String
fn save_to_string(&self) -> String
Save this game to a JSON string.
Sourcefn load_from_str(string: &str) -> Result<Self>
fn load_from_str(string: &str) -> Result<Self>
Load a game from a JSON string.
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.