Skip to main content

Crate base85n

Crate base85n 

Source
Expand description

§base85n

A Rust implementation of Base85N, an encoding for data that has to be embedded in a text-based format – JSON, XML, HTML, configuration files – where Base64 would otherwise be used and the size or the cleanliness of the result matters. It has a 4-byte-to-5-character Base85 core, an adaptive Dynamic Passthrough (DP) mode for partially human-readable, 1:1-efficiency output on favorable input, and a Fill mode that carries a run of up to 2048 identical bytes in five characters – or a short zero run together with the two bytes beside it. See spec/base85n-v0.5.0.md in the repository for the full specification.

let data = b"hello, world!";
let encoded = base85n::encode(data);
let decoded = base85n::decode(&encoded).unwrap();
assert_eq!(decoded, data);

The crate also exports a C ABI (see ffi) so that callers in other languages can link this implementation instead of a hand-written one; cargo build --release produces libbase85n.so/.dylib/.dll and libbase85n.a alongside the Rust library.

Modules§

constants
Named constants from spec sections 6.4 and 9.
ffi
C ABI for this crate: the same API as the C implementation’s c/include/base85n.h, backed by the Rust encoder and decoder.

Enums§

DecodeError
Errors that can occur while decoding a Base85N string.

Constants§

ALPHABET_N
Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. The 85-character alphabet used by Base85N, in index order (0-84).
PROFILES
Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. The eight donor profiles of spec section 4.2: each an ordered sequence of 13 distinct Alphabet-N characters.
RSET_ASCII
Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. Alphabet-N, the R-Set and the donor profiles of spec section 4. They are public because a binding layer – the python/ crate, say – has to be able to hand them to its own callers without a second copy of section 4. The 13 R-Set characters, indexed by R-Set index j (0-12), given as their ASCII byte value. See spec section 4.1.

Functions§

decode
Decode a Base85N string s back into the original bytes.
encode
Encode data as a Base85N string.
encode_parallel
Encode data on up to threads threads, producing exactly what encode produces.