Skip to main content

Crate rustbinary_derive

Crate rustbinary_derive 

Source
Expand description

Procedural derives used by rustbinary.

Applications normally enable the matching rustbinary feature and use the derives re-exported by the main crate. Generated paths intentionally refer to ::rustbinary, keeping the runtime traits and wire implementation owned by one crate. The procedural macro runs on the host with std, but generated code uses only core syntax and the selected RustBinary runtime traits, so consumers may expand these derives in no_std crates.

§Macro selection

  • Fingerprint generates a compatibility identifier for type structure and codec configuration.
  • StaticSize generates finite normal and bit-packed size bounds for statically sized values.
  • Reflect generates allocation-free structural metadata.
  • BitPacked generates a checked bit-level codec for bounded fields and nested BitPack values.
  • CompactBinary generates the schema-guided compact profile codec (CompactEncode + CompactDecode).

The generated implementations are not a replacement for the nextjson derives. Add NsonSerialize and NsonDeserialize when the value also crosses a normal rustbinary or CBOR wire profile. For the complete syntax and production constraints, see the package README and the re-exported runtime traits.

Derive Macros§

Archive
Derives the zero-copy archived mirror used by rustbinary::archive::build / OwnedArchive / MappedArchive.
BitPacked
Derives rustbinary::BitPack for structs and enums.
CompactBinary
Derives rustbinary::compact::CompactEncode and rustbinary::compact::CompactDecode — the schema-guided compact binary profile.
DecodeBounded
Derives rustbinary::DecodeBounded, the schema-derived resource cost algebra (B, A, D, W) = (max input bytes, max allocation, max nesting depth, max work) that mirrors the parser structure.
Fingerprint
Derives rustbinary::Fingerprint from structural type metadata.
Reflect
Derives allocation-free structural reflection metadata.
Serialize
Derives rustbinary::archive_codec::ArchiveWrite, the two-phase archive serializer (skeleton pass then bodies pass).
StaticSize
Derives compile-time normal and bit-packed size bounds.