gale.save.serialization module

The default save-file serializer/deserializer used by SaveManager. Both are plain functions, and both are accepted as constructor parameters, so a game that needs a different format (a more compact binary one, an encrypted one, a compressed one) can swap them out without changing anything else – the same pattern gale.net.serialization already uses for Server/Client.

Author: Alejandro Mujica (aledrums@gmail.com)

gale.save.serialization.json_serialize(envelope)[source]
Parameters:

envelope (Dict[str, Any]) – A JSON-serializable dict (SaveManager’s internal envelope: version, timestamps, metadata, and the game’s data).

Returns:

The UTF-8 encoded JSON representation of envelope.

Return type:

bytes

gale.save.serialization.json_deserialize(data)[source]
Parameters:

data (bytes) – Bytes produced by json_serialize (or a wire-compatible encoder).

Returns:

The decoded envelope dict.

Raises:

ValueError – If data is not valid JSON or does not decode to a dict.

Return type:

Dict[str, Any]