Skip to main content

Module encoding

Module encoding 

Source
Expand description

Generic base-N encoding/decoding with compile-time dictionaries.

Provides a unified interface for binary-to-text encodings (hex, base64, base32) with optimized runtime implementations and const-friendly fallbacks.

§Features

  • Const evaluation: All encoding/decoding logic works in const contexts
  • Zero-copy iterators: Streaming encoders and decoders with exact size hints
  • Optimized paths: Hand-tuned implementations for Base64/Base32
  • Flexible dictionaries: Support for custom alphabets and padding schemes
  • Stack allocation: Fixed-size ArrayStr and Array wrappers

§Submodules

  • hex: Hexadecimal encoding with upper/lowercase support
  • base64: Standard and URL-safe Base64 encodings
  • base64_url: URL-safe Base64 encodings
  • base32: RFC 4648 Base32, Base32-Hex, and Base32-DNS variants
  • base32_hex: RFC 4648 Base32-Hex
  • base32_dns: RFC 4648 Base32-DNS

§Examples

use omp_core::{base64, hex};

// Hex encoding
let encoded = hex::encode(b"Hello").into_string();
assert_eq!(encoded, "48656c6c6f");

// Base64 encoding
let encoded = base64::encode(b"Hello").into_string();
assert_eq!(encoded, "SGVsbG8=");

// Const evaluation
const HEX: hex::ArrayStr<5> = hex::encode_n(b"Hello");
assert_eq!(&*HEX, "48656c6c6f");

Modules§

base32
base32 encoding and decoding.
base64
base64 encoding and decoding.
base32_dns
base32_dns encoding and decoding.
base32_hex
base32_hex encoding and decoding.
base64_url
base64_url encoding and decoding.
hex
Hexadecimal encoding and decoding with streaming support.

Structs§

Array
A byte array wrapper that derefs to the decoded portion.
ArrayStr
An encoded string wrapper that stores the result.
DecodeWriter
A buffered writer that decodes encoded bytes before writing them to an inner writer.
Decoder
A streaming base-N decoder that converts encoded characters to bytes.
EncodeWriter
A buffered writer that encodes raw bytes before writing them to an inner writer.
Encoder
Iterator that encodes bytes as individual base-N ASCII characters.
Encoding
A compile-time dictionary for base-N encoding/decoding.

Enums§

DecodeError
Errors that can occur during base-N encoding/decoding operations.

Type Aliases§

Result
Result type for base-N operations.