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

#51 in Magic Beans

Download history 33426/week @ 2024-07-29 36934/week @ 2024-08-05 46897/week @ 2024-08-12 33422/week @ 2024-08-19 41381/week @ 2024-08-26 45930/week @ 2024-09-02 43575/week @ 2024-09-09 44993/week @ 2024-09-16 43668/week @ 2024-09-23 45992/week @ 2024-09-30 51449/week @ 2024-10-07 50245/week @ 2024-10-14 55461/week @ 2024-10-21 44700/week @ 2024-10-28 62033/week @ 2024-11-04 45543/week @ 2024-11-11

209,538 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

~2–2.7MB
~56K SLoC