Skip to main content

AssetSerializationBackend

Trait AssetSerializationBackend 

Source
pub trait AssetSerializationBackend: Send + Sync {
    // Required methods
    fn serialize(&self, asset: &SerializedAsset) -> Result<Vec<u8>>;
    fn deserialize(&self, bytes: &[u8]) -> Result<SerializedAsset>;
}
Expand description

Trait for implementing different asset serialization backends.

This trait allows for pluggable serialization strategies for assets, enabling support for different formats like JSON, MessagePack, bincode, etc. Implementations must be thread-safe (Send + Sync).

Required Methods§

Source

fn serialize(&self, asset: &SerializedAsset) -> Result<Vec<u8>>

Serializes a SerializedAsset into bytes using the backend’s format.

§Arguments
  • asset - The asset to serialize
§Returns

The serialized bytes on success, or an error if serialization fails

Source

fn deserialize(&self, bytes: &[u8]) -> Result<SerializedAsset>

Deserializes bytes back into a SerializedAsset using the backend’s format.

§Arguments
  • bytes - The serialized data to deserialize
§Returns

The deserialized SerializedAsset on success, or an error if deserialization fails

Implementors§