Function convert_bits
pub fn convert_bits<T>(
data: &[T],
from: u32,
to: u32,
pad: bool,
) -> Result<Vec<u8>, Error>Expand description
Convert between bit sizes
§Errors
Error::InvalidDataif any element ofdatais out of rangeError::InvalidPaddingifpad == falseand the padding bits are not0
§Panics
Function will panic if attempting to convert from or to a bit size that
is 0 or larger than 8 bits.
§Examples
use bech32::convert_bits;
let base5 = convert_bits(&[0xff], 8, 5, true);
assert_eq!(base5.unwrap(), vec![0x1f, 0x1c]);