Expand description
Fast, allocation-free hex encoding/decoding.
no_stdby default (scalar path)- Optional
stdsupport - Optional
simdaccelerated decode/validate on supported targets
§API
- Decode:
decode_to_slice,decode_to_array,decode_in_place - Encode:
encode_to_slice
§Examples
Decode hex → bytes:
use fast_hex_lite::decode_to_slice;
let hex = b"deadbeef";
let mut buf = [0u8; 4];
let n = decode_to_slice(hex, &mut buf).unwrap();
assert_eq!(&buf[..n], &[0xde, 0xad, 0xbe, 0xef]);Encode bytes → hex (lowercase):
use fast_hex_lite::encode_to_slice;
let src = [0xde, 0xad, 0xbe, 0xef];
let mut out = [0u8; 8];
let n = encode_to_slice(&src, &mut out, true).unwrap();
assert_eq!(&out[..n], b"deadbeef");Enums§
- Error
- Errors that can occur during hex encoding or decoding.
Functions§
- decode_
in_ place - Decode hex bytes in-place:
bufinitially contains ASCII hex; after decoding, the firstbuf.len() / 2bytes hold the result. - decode_
to_ array - Decode exactly
Nbytes from a hex string of length2*N. - decode_
to_ slice - Decode ASCII-hex bytes
src_hexintodst. - decoded_
len - Returns the number of bytes produced from a hex string of
hex_lenbytes. - encode_
to_ slice - Encode bytes into hex (lowercase or uppercase) into the provided output slice.
- encoded_
len - Returns the required output length (in bytes) for encoding
nbytes to hex.