Expand description
Encode the input bytes in the combined mode. output.len()
must be exactly
encoded_size(input.len())
.
If the std
feature is enabled, as it is by default, this will use multiple threads via Rayon.
Panics
Panics if the output slice is the wrong length.
Example
let input = b"some bytes";
let encoded_size = bao::encode::encoded_size(input.len() as u64);
assert!(encoded_size <= usize::max_value() as u128);
// Note that if you're allocating a new Vec like this, encode_to_vec is more convenient.
let mut encoded = vec![0; encoded_size as usize];
bao::encode::encode(input, &mut encoded);