PackageTrack
Sign in Get early access

bitfield-struct

Struct-like procedural macro for bitfields.

0.13.0 22M downloads/mo #1996 most downloaded on crates.io wrenger/bitfield-struct-rs

What this package is like to depend on

Last release 4 months ago

04 Apr 2026

Release timing varies

gaps range from 2 weeks to 6 months

Some releases are documented

notes for 10 of 40 stable releases

2 versions withdrawn

withdrawn after publishing

5 years old

42 releases · first in 2021

3 releases in the last 12 months

see the full history below

Release timeline

42 releases · Dec 2021 to Apr 2026
2022 2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 42
  1. 0.13.0 04 Apr 2026
    Release notes

    This release adds support for const generics.

    Bitfields can now use const generics directly. Just declare them on the struct as usual:

    use bitfield_struct::bitfield;
    
    #[bitfield(u16)]
    #[derive(PartialEq, Eq)]
    struct Packet<const VERSION: u8> {
        #[bits(4)]
        tag: u8,
        #[bits(12)]
        payload: u16,
    }
    Open source →
  2. 0.12.1 27 Oct 2025
    Release notes

    Support #[cfg(...)] on bit enum variants

    Open source →
  3. 0.12.0 23 Oct 2025
    Release notes

    This release contains a few fixes for #64 and #68, as well as optional support for the binrw traits #65 from @Maccraft123.

    Additionally, it introduces a small new macro for generating the from_bits/into_bits function for enums:

    use bitfield_struct::bitenum;
    
    #[bitenum]
    #[repr(u8)]
    #[derive(Debug, PartialEq, Eq)]
    enum MyEnum {
        #[fallback]
        A = 0,
        B = 1,
        C = 2,
    }
    
    assert_eq!(MyEnum::from_bits(1), MyEnum::B);
    assert_eq!(MyEnum::C.into_bits(), 2);
    
    #[bitfield(u8)]
    struct Test {
        #[bits(8)]
        value: MyEnum,
    }

    Thanks to @MolotovCherry and @xTachyon for reporting these issues.

    Open source →
  4. 0.11.0 04 May 2025
    Release notes

    Add the option to auto-generate std::hash::Hash as suggested by @freemin7 #62

    #[bitfield(u32, hash = true)]
    struct MyBitfield {
        data: u16,
        __: u8,
        #[bits(8)]
        extra: u8,
    }

    The hash implementation ignores any padding, but requires that all fields also implement Hash (similar to Debug).

    Thanks to @freemin7 for suggesting this.

    Open source →
  5. 0.10.1 26 Jan 2025
    Release notes

    Fix clippy unnecessary cast warning #60.
    Thanks to @martiege for reporting this.

    Open source →
  6. 0.10.0 19 Dec 2024
    Release notes

    This release includes an option to disable automatic Copy and Clone implementation. This might be useful when you want to implement your own Clone.

    /// We have a custom clone implementation -> opt out
    #[bitfield(u64, clone = false)]
    struct Full {
        data: u64,
    }
    
    impl Clone for Full {
        fn clone(&self) -> Self {
            Self::new().with_data(self.data())
        }
    }
    
    impl Copy for Full {}

    Thanks to @kevinhartman for implementing this :)

    From this release on, the set_<field> and set_<field>_checked setters are const. This is possible due to Rust 1.83.0 stabilizing const mut refs. Consequently, the minimum supported Rust version was bumped to 1.83.0. This also opens the door to a more generic bitfield representation (#7).

    Open source →
  7. 0.9.5 26 Jan 2025
    Release notes

    Fix clippy unnecessary cast warning #60.
    Thanks to @martiege for reporting this.

    Open source →
  8. 0.9.4 26 Jan 2025
    Release notes

    Backport making Copy and Clone optional (#59).

    This release is intended to support older rust versions, that lack the const_mut_refs feature.

    Open source →
  9. 0.9.3 03 Dec 2024
    Release notes

    This release fixes that defaults for padding were not correctly applied on Msb ordering #57.

    Thanks to @gregorygaines for finding and fixing this bug.

    Open source →
  10. 0.9.2 15 Oct 2024
    Release notes

    This release fixes a clippy warning for certain edge cases #53.

    Thanks to @s5suzuki for reporting this.

    Open source →
  11. 0.9.1 13 Oct 2024

    Nothing published for this version

  12. 0.9.0 23 Sep 2024

    Nothing published for this version

  13. 0.8.0 20 Jun 2024

    Nothing published for this version

  14. 0.7.0 07 Jun 2024

    Nothing published for this version

  15. 0.6.2 23 May 2024

    Nothing published for this version

  16. 0.6.1 14 Apr 2024

    Nothing published for this version

  17. 0.6.0 16 Feb 2024

    Nothing published for this version

  18. 0.5.6 10 Dec 2023

    Nothing published for this version

  19. 0.5.5 11 Nov 2023

    Nothing published for this version

  20. 0.5.4 31 Aug 2023

    Nothing published for this version

  21. 0.5.3 30 Jul 2023

    Nothing published for this version

  22. 0.5.2 27 Jun 2023

    Nothing published for this version

  23. 0.5.1 27 Jun 2023

    Nothing published for this version

  24. 0.5.0 27 Jun 2023 withdrawn

    Nothing published for this version

  25. 0.4.4 05 Jun 2023

    Nothing published for this version

  26. 0.4.3 26 May 2023

    Nothing published for this version

  27. 0.4.2 17 May 2023

    Nothing published for this version

  28. 0.4.1 31 Mar 2023

    Nothing published for this version

  29. 0.4.0 31 Mar 2023 withdrawn

    Nothing published for this version

  30. 0.3.2 24 Jan 2023

    Nothing published for this version

  31. 0.3.1 14 Jan 2023

    Nothing published for this version

  32. 0.3.0 14 Jan 2023

    Nothing published for this version

  33. 0.2.0 23 Dec 2022

    Nothing published for this version

  34. 0.1.8 07 Dec 2022

    Nothing published for this version

  35. 0.1.7 05 May 2022

    Nothing published for this version

  36. 0.1.6 08 Apr 2022

    Nothing published for this version

  37. 0.1.5 19 Mar 2022

    Nothing published for this version

  38. 0.1.4 12 Jan 2022

    Nothing published for this version

  39. 0.1.3 12 Jan 2022

    Nothing published for this version

  40. 0.1.2 09 Jan 2022

    Nothing published for this version

  41. 0.1.1 28 Dec 2021

    Nothing published for this version

  42. 0.1.0 21 Dec 2021

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive