9 releases (breaking)

new 0.7.0 Nov 15, 2024
0.6.0 Apr 29, 2024
0.5.0 Feb 7, 2024
0.4.0 Jun 20, 2023
0.0.1 Sep 14, 2022

#45 in #parity

Download history 35130/week @ 2024-07-26 36251/week @ 2024-08-02 46037/week @ 2024-08-09 34174/week @ 2024-08-16 39694/week @ 2024-08-23 44508/week @ 2024-08-30 44156/week @ 2024-09-06 44185/week @ 2024-09-13 46649/week @ 2024-09-20 40841/week @ 2024-09-27 53991/week @ 2024-10-04 50440/week @ 2024-10-11 54179/week @ 2024-10-18 48638/week @ 2024-10-25 58395/week @ 2024-11-01 48453/week @ 2024-11-08

218,387 downloads per month
Used in 122 crates (8 directly)

Apache-2.0

49KB
828 lines

scale-bits · CI Status Latest Version on Crates.io Released API docs

This small utility crate provides two separate things:

  1. A Bits type that can be SCALE encoded and decoded, and is fully SCALE compatible with a BitVec<u8, Lsb0>. It's a deliberately simple type that is conceptually just a sequence of bools, and can be used as a replacement for BitVec when you don't need the additional complexity and functionality that it comes with. See the bits module for more.
  2. Utility methods to help encode and decode arbitrary bit sequences from their SCALE representation, or skip over the corresponding bytes entirely, with zero allocations. These bypass the need to first go via some BitVec with the right store/order type, and are WASM compatible (unlike BitVec's u64 store type). See the scale module for more.

These things play nicely together (ie you can encode and decode arbitrary bit sequences directly into the Bits type), but don't need to be used together.

Dependencies

~3.5MB
~77K SLoC