#serialization #compile-time #version #data #deserialize #immutability #checking

vbs

Version-tagged serialization adaptor with compile-time version checking

5 releases

0.1.7 Oct 22, 2024
0.1.6 Jun 3, 2024
0.1.5 May 29, 2024
0.1.4 Apr 1, 2024
0.1.3 Mar 27, 2024

#785 in Encoding

Download history 526/week @ 2024-10-06 510/week @ 2024-10-13 1067/week @ 2024-10-20 866/week @ 2024-10-27 939/week @ 2024-11-03 819/week @ 2024-11-10 1196/week @ 2024-11-17 714/week @ 2024-11-24 1177/week @ 2024-12-01 1154/week @ 2024-12-08 806/week @ 2024-12-15 171/week @ 2024-12-22 212/week @ 2024-12-29 1315/week @ 2025-01-05 715/week @ 2025-01-12 788/week @ 2025-01-19

3,031 downloads per month
Used in 2 crates

MIT license

17KB
346 lines

vbs

Provides the following:

  • a trait StaticVersionType for constraining to a version (major.minor) at compile-time.
    • sealed to a struct StaticVersion<const MAJOR: u16, const MINOR: u16>.
    • for the purposes of version enforcement, patch versions are not treated as a type change.
  • a struct Version for runtime operations against a version, without requiring dyn
    • used to [de]serialize a version in a strictly defined and immutable form, so that updates to the serialization format iteself can be a version controlled property.
    • does not include patch level, prerelease identifiers, or build metadata; this is not intended to be a general purpose semver crate.
  • a trait BinarySerializer, an adaptor that can be implemented around any data format that adapts the serde data model.
    • by default, serializes a version prefix before each top-level serialization, and verifies version compatibility when deserializing the serialized message.
    • supports unversioned [de]serialize_no_version operations, which, by default, should simply be the same as calling type.serialize(serializer) for the embedded serializer.
  • implementations against existing data formats

Dependencies

~0.7–1.3MB
~29K SLoC