pub fn hex_string<const N: usize>(src: &[u8]) -> Result<String<N>, Error>Available on crate feature
heapless-08 only.Expand description
Encodes src as a lowercase hexadecimal string with inline capacity N.
Every byte produces two ASCII digits, with no prefix or separators. The
result owns its storage without allocating. Empty input succeeds even when
N is zero. Any unused capacity remains available on the returned string.
§Errors
Returns Error::Overflow if twice the input length cannot be represented,
or Error::OutputTooSmall if N is less than the encoded byte length.
Insufficient capacity is an error rather than a panic.
§Examples
use faster_hex::{heapless_08::hex_string, Error};
assert_eq!(hex_string::<4>(&[0xab, 1])?.as_str(), "ab01");
assert!(matches!(hex_string::<3>(&[0xab, 1]),
Err(Error::OutputTooSmall { required: 4, .. })));
assert_eq!(hex_string::<0>(&[])?.as_str(), "");