#proc-macro #id #type-id #volatile #counter #locking #vtid

macro vtid-proc

Procedural macro implementation for vtid - volatile type ID generation

4 releases

new 0.1.3 Nov 14, 2024
0.1.2 Nov 14, 2024
0.1.1 Nov 14, 2024
0.1.0 Nov 14, 2024

#1629 in Rust patterns

Download history 286/week @ 2024-11-11

286 downloads per month
Used in vtid

MIT/Apache

6KB
92 lines

Volatile Type ID (Vtid) generator.

How it works

  1. Each time a crate is recompiled, a counter in a lock file is incremented to create a new version
  2. This version becomes the base ID for all types in that compilation unit
  3. When combined with type information, it creates unique IDs that:
    • Are consistent for the same type within one compilation
    • Automatically version bump on recompilation
    • Allow tracking type changes across hot reloads
    • Maintain thread-safety through file locking

The versioning ensures that if a type's definition changes and the crate is recompiled, the old and new versions of the type will have different IDs.

Dependencies

~1.3–1.8MB
~39K SLoC