Expand description
SIMD-accelerated base64 encoding and decoding.
§Examples
let bytes = b"hello world";
let base64 = base64_simd::STANDARD;
let encoded = base64.encode_to_string(bytes);
assert_eq!(encoded, "aGVsbG8gd29ybGQ=");
let decoded = base64.decode_to_vec(encoded).unwrap();
assert_eq!(decoded, bytes);
§Profile settings
To ensure maximum performance, the following profile settings are recommended when compiling this crate:
opt-level = 3
lto = "fat"
codegen-units = 1
§CPU feature detection
The feature flag detect
is enabled by default.
When the feature flag detect
is enabled, the APIs will test at runtime whether the CPU (and OS) supports the required instruction set. The runtime detection will be skipped if the fastest implementation is already available at compile-time.
When the feature flag detect
is disabled, the APIs will test at compile-time whether the compiler flags supports the required instruction set.
If the environment supports SIMD acceleration, the APIs will call SIMD functions under the hood. Otherwise, the APIs will call fallback functions.
When the feature flag unstable
is enabled, this crate requires the nightly toolchain to compile.
§no_std
support
You can disable the default features to use this crate in a no_std
environment.
You can enable the feature flag alloc
if the environment supports heap allocation.
Currently the feature flag detect
depends on the standard library. Dynamic CPU feature detection is not available in no_std
environments.
Structs§
Constants§
- STANDARD
- Standard charset with padding.
- STANDARD_
NO_ PAD - Standard charset without padding.
- URL_
SAFE - URL-Safe charset with padding.
- URL_
SAFE_ NO_ PAD - URL-Safe charset without padding.
Traits§
- Append
Base64 Decode - Types that can append bytes decoded from from a base64 string.
- Append
Base64 Encode - Types that can append a base64 string.
- AsOut
- Extension trait for converting a mutable reference to an out reference.
- From
Base64 Decode - Types that can be decoded from a base64 string.
- From
Base64 Encode - Types that can represent a base64 string.
Functions§
- forgiving_
decode - Forgiving decodes a base64 string to bytes.
- forgiving_
decode_ inplace - Forgiving decodes a base64 string to bytes and writes inplace.
- forgiving_
decode_ to_ vec - Forgiving decodes a base64 string to bytes and returns a new
Vec<u8>
.