yabase
Types
Issue #74: re-export CodecError so callers who only
import yabase can type-annotate around encode / decode /
encode_multibase / decode_multibase without reaching into
yabase/core/error. The alias keeps the type identity (same
CodecError the underlying functions return), so error values
flow through unchanged.
pub type CodecError =
error.CodecError
Values
pub fn decode(
enc: encoding.Encoding,
value: String,
) -> Result(BitArray, error.CodecError)
Decode a string using the specified encoding.
pub fn decode_multibase(
value: String,
) -> Result(encoding.Decoded, error.CodecError)
Decode a multibase-prefixed string, auto-detecting encoding.
Inspect the result with encoding.decoded_encoding/1 and
encoding.decoded_data/1 — the Decoded type is opaque so its
representation can evolve without breaking external pattern matches.
pub fn encode(
enc: encoding.Encoding,
data: BitArray,
) -> Result(String, error.CodecError)
Encode data using the specified encoding. Returns Result because some encodings (Base85 Z85/Rfc1924) have input length constraints.
pub fn encode_multibase(
enc: encoding.Encoding,
data: BitArray,
) -> Result(String, error.CodecError)
Encode with a multibase prefix. Returns Error for encodings without a defined prefix.