Registry / serialization / packed-struct

packed-struct

JSON →
library0.10.1rscratesunverified

Binary-level structure packing and unpacking generator for Rust.

# Cargo.toml [dependencies] packed_struct = "0.10.1"
INSTALL
IMPORT
SIG · PACKED-STRUCT
P
packed-struct
serializationrustv0.10.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PackedStruct
use packed_struct::PackedStruct;

Defines a packed struct and packs it into bytes.

use packed_struct::PackedStruct; use packed_struct::prelude::*; #[derive(PackedStruct)] #[packed_struct(bit_numbering="msb0")] pub struct Test { #[packed_field(bits="0..=3")] field: Integer<u8, packed_bits::Bits4>, } fn main() { let test = Test { field: 5.into() }; let packed = test.pack().unwrap(); println!("Packed bytes: {:?}", packed); }
Debug
Known issues
gotchaBit numbering and field alignment can be tricky; incorrect settings may cause unexpected packing.
fix
Double-check the bit numbering (msb0/lsb0) and field bit ranges.
affects: >=0.10.0
Upgrade
Version history
0.10.1latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
packed-struct — cargo add packed-struct · libregistry