pub struct MsgpackAssetSerializationBackend;Expand description
MessagePack-based asset serialization backend.
This backend uses rmp_serde to serialize and deserialize assets in MessagePack format. MessagePack is a compact binary format that provides efficient serialization with smaller output sizes and faster processing compared to text-based formats like JSON.
§Performance Characteristics
- Serialization: Fast speed, compact binary output
- Deserialization: Fast speed, efficient memory usage
- Storage: Space-efficient binary format, ideal for production environments
§Example
let backend = MsgpackAssetSerializationBackend;
// Use backend for serialization operations
asset_manager.set_serialization_backend(Box::new(backend));Trait Implementations§
Source§impl AssetSerializationBackend for MsgpackAssetSerializationBackend
impl AssetSerializationBackend for MsgpackAssetSerializationBackend
Source§fn serialize(&self, asset: &SerializedAsset) -> Result<Vec<u8>>
fn serialize(&self, asset: &SerializedAsset) -> Result<Vec<u8>>
Serializes a SerializedAsset to MessagePack bytes.
Uses rmp_serde internally to convert the asset to a compact binary format. MessagePack provides excellent space efficiency and fast serialization performance.
§Arguments
asset- The asset to serialize
§Returns
A vector of bytes containing the MessagePack representation, or an error if serialization fails (e.g., due to unsupported data types).
Source§fn deserialize(&self, bytes: &[u8]) -> Result<SerializedAsset>
fn deserialize(&self, bytes: &[u8]) -> Result<SerializedAsset>
Deserializes MessagePack bytes back into a SerializedAsset.
Parses the provided MessagePack bytes and reconstructs a SerializedAsset. The binary data must be valid MessagePack that matches the expected structure.
§Arguments
bytes- MessagePack bytes to deserialize
§Returns
The reconstructed SerializedAsset, or an error if the data is corrupted or doesn’t match the expected MessagePack structure.
Auto Trait Implementations§
impl Freeze for MsgpackAssetSerializationBackend
impl RefUnwindSafe for MsgpackAssetSerializationBackend
impl Send for MsgpackAssetSerializationBackend
impl Sync for MsgpackAssetSerializationBackend
impl Unpin for MsgpackAssetSerializationBackend
impl UnsafeUnpin for MsgpackAssetSerializationBackend
impl UnwindSafe for MsgpackAssetSerializationBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.