Expand description
Binary (de)serialization framework that is backwards compatible with versioned fields.
#[derive(Serializable, PartialEq, Debug)]
pub struct Player {
// This field has existed since binary version 0.0.1
#[since(0.0.1)]
pub id: u32,
// In 0.0.2 we introduced a new field
// When loading a serialized 0.0.1 object, this field will have it's `Default` value
#[since(0.0.2)]
pub name: String,
}
let player = Player {
id: 5,
name: String::from("foo")
};
let serialized = binver::to_vec(&player);
let deserialized_player = binver::deserialize_slice(&serialized).unwrap();
assert_eq!(player, deserialized_player);
Structs§
- Read
Config - Configuration passed to a read function
- Version
- SemVer version as defined by https://semver.org.
Enums§
- Read
Error - Error thrown while reading
- Write
Error - Error thrown while writing
Traits§
- Reader
- Generic reader
- Serializable
- The main trait of this crate that is used for (de)serialization
- Writer
- Generic writer
Functions§
- deserialize_
slice - Deserialize an object from the given slice.
- deserialize_
slice_ with_ config - Deserialize an object from the given slice with the given
ReadConfig
. SeeReadConfig
for information on the options. - to_vec
- Serialize the given
Serialiazable
object to a vec - write_
to_ slice - Serialize the given
Serializable
object to the given slice. The amount of bytes written is returned.
Type Aliases§
- Read
Result - Result type to be returned from any read action
- Write
Result - Result type to be returned from any write action