pub fn bech32_encode_to_fmt<F, T>(
    fmt: &mut F,
    hrp: &str,
    data: T,
    variant: Variant
) -> Result<Result<(), Error>, Error>
where F: Write, T: AsRef<[u5]>,
Expand description

NOTE: The below code is copied with minor alterations from the bech32 crate. These alterations are to avoid using std for allocations, and fit with the sbor no-alloc options.

The original source for the bech32 crate is under MIT license: https://crates.io/crates/bech32 This license permits modification without restriction, but requires the license copying below.

Important additional note - the use of this modified code is also covered under the Radix license, as per all code in this repository.


MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Encode a bech32 payload to an fmt::Write. This method is intended for implementing traits from std::fmt. This method uses the std::fmt traits

§Errors

  • If [check_hrp] returns an error for the given HRP.

§Deviations from standard

  • No length limits are enforced for the data part