pub trait SerializationStrategy: Send + Sync {
// Required methods
fn get_strategy_id(&self) -> &'static str;
fn serialize(&self, world: &World) -> Result<Vec<u8>, SerializationError>;
fn deserialize(
&self,
data: &[u8],
world: &mut World,
) -> Result<(), DeserializationError>;
}Expand description
The abstract contract for a scene serialization strategy Lane.
Each concrete implementation of this trait represents a different method
of converting a World to and from a persistent format.
Required Methods§
Sourcefn get_strategy_id(&self) -> &'static str
fn get_strategy_id(&self) -> &'static str
Returns the unique, versioned string identifier for this strategy.
This ID is written to the SceneHeader and used by the SerializationAgent
to look up the correct strategy from its registry during deserialization.
Example: "KH_RECIPE_V1".
Sourcefn deserialize(
&self,
data: &[u8],
world: &mut World,
) -> Result<(), DeserializationError>
fn deserialize( &self, data: &[u8], world: &mut World, ) -> Result<(), DeserializationError>
Deserializes data from a byte payload to populate the given World.
This method should assume the SceneHeader has already been parsed and validated,
and that data is the correct payload for this strategy.
§Arguments
data- The raw byte payload to deserialize.world- A mutable reference to the world to be populated.
§Returns
A Result indicating success or a DeserializationError.