9 releases (breaking)

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

#30 in #parity

Download history 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 48485/week @ 2024-11-08 46815/week @ 2024-11-15 44240/week @ 2024-11-22 44841/week @ 2024-11-29 38850/week @ 2024-12-06

183,501 downloads per month
Used in 124 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

~2–2.8MB
~57K SLoC