base16 (hex) encoding for Rust.
This is a base16 (e.g. hexadecimal) encoding and decoding library which was initially written with an emphasis on performance.
This was before Rust added SIMD, and I haven't gotten around to adding that. It's still probably the fastest non-SIMD impl.
Usage
Add base16 = "0.2"
to Cargo.toml, then:
More usage examples in the docs.
no_std
Usage
This crate supports use in no_std
configurations using the following knobs.
- The
"alloc"
feature, which is on by default, adds a number of helpful functions that require use of thealloc
crate, but not the rest ofstd
. This isno_std
compatible.- Each function documents if it requires use of the
alloc
feature.
- Each function documents if it requires use of the
- The
"std"
feature, which is on by default, enables the"alloc"
feature, and additionally makesbase16::DecodeError
implement thestd::error::Error
trait. (Frustratingly, this trait is instd
and not incore
oralloc
...)
For clarity, this means that by default, we assume you are okay with use of std
.
If you'd like to disable the use of std
, but are in an environment where you have
an allocator (e.g. use of the alloc
crate is acceptable), then you require this as alloc
-only as follows:
[]
# Turn of use of `std` (but leave use of `alloc`).
= { = "0.2", = false, = ["alloc"] }
If you just want the core base16
functionality and none of the helpers, then
you should turn off all features.
[]
# Turn of use of `std` and `alloc`.
= { = "0.2", = false }
Both of these configurations are no_std
compatible.
License
Public domain, as explained here