Module utils
Source - BIT_MASKS 🔒
- bit
- Get
i-th bit from bytes slice. Index i starts from 0. - bits_to_bytes
- Convert bits, Vec slice of
bool into bytes, Vec<u8>. - bits_to_usize
- Convert a Vec slice of bit or
bool into a number as usize. - bytes_to_bits
- Convert a bytes slice into a Vec of bit.
- bytes_to_int
- Convert big-endian bytes into base10 or decimal number.
- bytes_to_slicebit
- Convert (bytes slice + Range) representation into bits in forms of
Vec<bool>. - cast
- Cast from a typed scalar to another based on
num_traits - get_sorted_indices
- Get sorted indices from unsorted slice.
- int_to_bytes
- Get a compressed bytes (leading-zero-truncated big-endian bytes) from a
u64. - len_lcp
- Get length of the longest common prefix bits for the given two slices.
- nbytes_across
- Get the required length of bytes from a
Range, bits indices across the bytes. - random_byte
- Generate a random byte based on
rand::random. - random_bytes
- Generate random bytes of the given length.
- random_hash
- Generate a random
Hash, byte-array of HASH_LEN length. - random_hashes
- Generate a vector of random
Hash with the given length. - shuffle
- Shuffle a slice using Fisher-Yates algorithm.
- slice_to_hash
- Get a fixed length byte-array or
Hash from slice.