bdk_chain::bitcoin::bech32

Function encoded_length

pub fn encoded_length<Ck>(
    hrp: Hrp,
    data: &[u8],
) -> Result<usize, CodeLengthError>
where Ck: Checksum,
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.