Trait Format

Source
pub trait Format {
    // Required methods
    fn serialize<W: Write, T: Serialize>(
        writer: W,
        value: &T,
    ) -> Result<(), Error>;
    fn deserialize<R: Read, S: for<'de> DeserializeSeed<'de, Value = T>, T>(
        reader: R,
        seed: S,
    ) -> Result<T, Error>;

    // Provided method
    fn extension() -> &'static str { ... }
}
Expand description

Handles serialization and deserialization of save data.

Required Methods§

Source

fn serialize<W: Write, T: Serialize>(writer: W, value: &T) -> Result<(), Error>

Serializes a value with the format.

§Errors

If serialization fails.

Source

fn deserialize<R: Read, S: for<'de> DeserializeSeed<'de, Value = T>, T>( reader: R, seed: S, ) -> Result<T, Error>

Deserializes a value with the format.

§Errors

If deserialization fails.

Provided Methods§

Source

fn extension() -> &'static str

The file extension used by the format.

Defaults to .sav.

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§

Source§

impl Format for JSONFormat

Source§

impl Format for RMPFormat

Source§

impl<F: Format> Format for Brotli<F>

Available on crate feature brotli only.