Skip to main content

encode

Function encode 

Source
pub fn encode(data: &[u8]) -> String
Expand description

Encodes binary data into a Base122 string.

The resulting string is guaranteed to be valid UTF-8 and is more compact than Base64, typically resulting in only ~14% size overhead.

§Performance

This function utilizes a fast-path execution model that scans 8-byte chunks using SWAR logic. It is optimized for long buffers where ASCII-compatible sequences are common.

§Examples

let data = b"data";
let encoded = base122_fast::encode(data);
assert!(!encoded.is_empty());