Repository navigation
v0.26.0
Changed
- Breaking: consolidate the public API in
yabase.encode(data, using:),decode(value, using:),encode_multibase(data, using:)anddecode_multibase(value)replace the old root argument order,core/encoding.encode/decode_as,core/multibase.encode_with_prefix/decode/decode_bytes, codec-levelencode/decode, and allfacade.encode_*/decode_*shortcuts. Every encoder returnsResult(String, CodecError)and rejects partial bytes withUnalignedInput(bit_size). - Replace the selection helpers in
core/encodingwith publicEncodingconstructors. RemoveBase32Variant,Base58Variant,Base64VariantandBase85Variant; their choices are direct encoding variants.Base16Lowercaseretainsbase16.encode_lowercaseandfacade.encode_base16_lowercase.Base32CrockfordCheckretainsencode_check/decode_check, andBech32Encoding(hrp, Bech32m)retainsbech32.encode_default. - Move
CodecError,Encoding,Decoded,Base58CheckDecoded,Bech32Decoded,Bech32Variant,int53_maxandint64_maxto the root. Remove theCodecErroraliases,decoded_data/decoded_encodinggetters, and opacity from the decoded records. Their fields are public.decode_base58checkanddecode_bech32preserve automatic metadata decoding;decode_base16_strict,decode_base32_strictanddecode_base64_strictpreserve the three strict decoders. - Replace
intid.encode_int_*,decode_int_*,decode_int_*_boundedanddecode_int_boundedwithencode_int(value, using:)anddecode_int(value, using:, up_to:). Keepencode_int_base16_compactfor its distinct spelling anddecode_int_base58check(value, up_to:)for version-independent decoding. All ten integer formats remain supported, with inclusive optional bounds, canonical representations and existing target limits. - Rename
multibase_nametoencoding_to_stringandfrom_multibase_prefixtoencoding_from_multibase_prefix; keepmultibase_prefixat the root. Preserve all 23 accepted prefixes. RemoveTarget,target_erlang,target_javascript,supports_targetandis_javascript_safe; every byte codec supports both targets.IntCodec,int_codec,normalise_for_multibase_prefixandcore/guard.assert_byte_alignedare no longer public. Multibase normalization and byte alignment are handled by the consuming operations. - Distinguish invalid Base58Check versions and metadata mismatches with
InvalidVersion,UnexpectedVersion,UnexpectedHrpandUnexpectedBech32Variant. Bech32 reportsMixedCaseandNonZeroPadding; Adobe reportsMissingDelimiterwith an original-input insertion boundary. Actual checksum failures remainInvalidChecksum. - Delegate hexadecimal and the four ASCII Base64 encoders to
gleam_stdlibafter byte-alignment validation. Keep format-specific decoders for their diagnostics and accepted wire forms.
For example, the former Base64 facade call returned a string:
// Before
import yabase/facade
let encoded = facade.encode_base64(<<"Hello":utf8>>)
// After
import yabase
let assert Ok(encoded) = yabase.encode(<<"Hello":utf8>>, using: yabase.Base64)Fixed
- Report the original invalid grapheme and its zero-based position through compact hexadecimal padding, Bech32 separators, Adobe outer whitespace, multibase prefixes and Crockford ignored hyphens. ASCII case folding no longer changes the character reported to callers.
- Reject a combining mark immediately after Adobe's opening delimiter instead of dropping it and sometimes accepting malformed input as empty bytes. Delimiters are sliced by their ASCII byte width. Preserve the existing empty
<~>spelling and the canonical<~~>output, and use the same outer whitespace set on both targets and supported standard-library versions. - Keep Base58Check wire/checksum validation before expected-version validation, and distinguish a valid payload with mismatched metadata from a bad checksum. Preserve error precedence before optional integer bounds.
Documentation
- Rewrite public API docs and executable examples around the root API. Shorten README and update contribution and testing instructions. Strengthen README verification so zero discovered examples or an incomplete code fence fails, and preserve the complete generated multibase registry table.