Trait hexgame::Serialization
source · [−]pub trait Serialization: Sized {
fn save_to_json(&self) -> Value;
fn load_from_json(value: Value) -> Result<Self>;
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
fn save_to_json(&self) -> Value
fn save_to_json(&self) -> Value
Save this game as a Serde JSON value
fn 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
fn save_to_string(&self) -> String
fn save_to_string(&self) -> String
Save this game to a JSON string.
fn load_from_str(string: &str) -> Result<Self>
fn load_from_str(string: &str) -> Result<Self>
Load a game from a JSON string.