scale_bits/
lib.rs

1// Copyright (C) 2024 Parity Technologies (UK) Ltd. (admin@parity.io)
2// This file is a part of the scale-value crate.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//         http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! This small utility crate provides two separate things:
17//!
18//! 1. A [`Bits`] type that can be SCALE encoded and decoded, and is fully
19//!    SCALE compatible with a `BitVec<u8, Lsb0>`. It's a deliberately simple
20//!    type that is conceptually just a sequence of bools, and can be used as
21//!    a replacement for `BitVec` when you don't need the additional complexity
22//!    and functionality that it comes with. See the [`mod@bits`] module for more.
23//! 2. Utility methods to help encode and decode arbitrary bit sequences from their
24//!    SCALE representation, or skip over the corresponding bytes entirely, with zero
25//!    allocations. These bypass the need to first go via some `BitVec` with the
26//!    right store/order type, and are WASM compatible (unlike `BitVec`'s `u64` store
27//!    type). See the [`scale`] module for more.
28//!
29//! These things play nicely together (ie you can encode and decode arbitrary bit
30//! sequences directly into the [`Bits`] type), but don't need to be used together.
31
32#![deny(missing_docs)]
33#![no_std]
34
35extern crate alloc;
36
37pub mod bits;
38pub mod scale;
39
40// Export the common things at root:
41
42pub use bits::Bits;
43pub use scale::{
44	decode_using_format_from, encode_using_format, encode_using_format_to, format::Format,
45};