Function bech32::encoded_length

source ·
pub fn encoded_length<Ck: Checksum>(
    hrp: Hrp,
    data: &[u8]
) -> Result<usize, CodeLengthError>
Expand description

Checks that encoding hrp and data creates a code that is less than the code length for Ck.

The length of the code is how long a coded message can be (including the checksum!) for the code to retain its error-correcting properties.

§Returns

Ok(encoded_string_length) if the encoded length is less than or equal to Ck::CODE_LENGTH otherwise a CodeLengthError containing the encoded length and the maximum allowed.