Module hex
Expand description
Hexadecimal encoding and decoding utilities.
Use crate::fmt::hex to borrow bytes as a configurable Hex view.
The view supports deferred formatting, owned text output, and writing into
existing strings, byte buffers, or slices. Encoding defaults to lowercase
without a prefix and works with no_std + alloc.
The byte/pair helpers are also useful in URI percent-encoding and decoding.
Use decode to decode into a vector or fixed-size array.
Structs§
- Buffer
TooSmall - The destination cannot hold the complete hex encoding.
- Format
- Shared hex representation for encoding and decoding.
- Hex
- A borrowed view that encodes bytes as hex digits with optional framing.
Enums§
- Decode
Error - Invalid hex input or an incompatible output size. Indices are byte offsets in the original input, including prefix/separators.
- Decode
Write Error std - Invalid input or an I/O failure while writing decoded bytes.
Traits§
- FromHex
- An owned destination for decoded bytes.
Functions§
- decode
- Decode compact hex into an inferred vector or fixed-size array.
- decode_
append - Append decoded bytes to a collection, returning the number supplied to it.
- decode_
into - Decode into an existing slice-like buffer, returning its written portion.
- decode_
pair - Decode a
%XX-style hex pair to its byte value, orNoneif either nibble is not a valid hex digit. - decode_
upper_ pair - Decode two uppercase ASCII hex digits to one byte.
- decode_
write std - Decode into a byte writer without allocating an intermediate vector.
- encode_
byte_ lower - Encode one byte as two lowercase ASCII hex digits.
- encode_
byte_ upper - Encode one byte as two uppercase ASCII hex digits.
- nibble
- ASCII hex digit →
0..=15,Nonefor non-hex bytes. - upper_
nibble - Uppercase ASCII hex digit to
0..=15.