1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
pub
/// Packable implementation for [`bnum`](https://crates.io/crates/bnum) types.
/// Packable implementation for [`ruint`](https://crates.io/crates/ruint) types.
/// A trait for types that can be packed into a single value, which
/// can be used for varint encoding.
///
/// This trait is used to define how to pack and unpack values of
/// different types into a single value.
///
/// A common usage is to pack `Self` and `Rhs` into a single
/// value `Packed`, if the `Packed` implements [`Varint`](crate::Varint),
/// then the packed value can be used for varint encoding in one go.
/// However, the output size of the packed value is not guaranteed to be
/// smaller than seperate encoding of `Self` and `Rhs`, and most of the
/// time, the output size is larger than the sum of encoding two types separately.
///
/// The `Rhs` type is the type that will be packed with the current
/// type.
///
/// The `Packed` type is the type that will be used to store the
/// packed value.