Skip to main content

Crate base122_fast

Crate base122_fast 

Source
Expand description

§Base122-Fast

A high-performance Base122 implementation achieving throughput up to 6.5 Gbps (encoding) and 6.2 Gbps (decoding) on modern hardware (e.g., AMD Ryzen 5 5600, single-threaded).

Base122 is a binary-to-text encoding scheme that is significantly more space-efficient than Base64, offering approximately 14% overhead compared to Base64’s 33%, while remaining valid UTF-8.

§Key Features

  • High Throughput: Optimized for Gbps-level processing.
  • no_std: Suitable for embedded systems and WASM (requires alloc).
  • SIMD Within A Register: Uses SWAR techniques to process multiple bytes in 64-bit registers.
  • Safety: While leveraging unsafe for performance, it is rigorously tested for round-trip integrity.

§Quick Start

let data = b"hello world";
let encoded = base122_fast::encode(data);
let decoded = base122_fast::decode(&encoded).expect("Failed to decode");

assert_eq!(data, decoded.as_slice());

Functions§

decode
Decodes a Base122 encoded string back into its original binary form.
encode
Encodes binary data into a Base122 string.