Trait Serialization

Source
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§

Source

fn save_to_json(&self) -> Value

Save this game as a Serde JSON value

Source

fn load_from_json(value: Value) -> Result<Self>

Load a game from a Serde JSON value.

Provided Methods§

Source

fn save_to_string(&self) -> String

Save this game to a JSON string.

Source

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.

Implementors§