Crate const_hex

Source
Expand description

githubcrates-iodocs-rs

This crate provides a fast conversion of byte arrays to hexadecimal strings, both at compile time, and at run time.

It aims to be a drop-in replacement for the hex crate, as well as extending the API with const-eval, a const-generics formatting buffer, similar to itoa’s, and more.

Version requirement: rustc 1.64+

Re-exports§

pub use traits::ToHexExt;alloc
pub use self::serde::deserialize;
pub use self::serde::serialize;alloc
pub use self::serde::serialize_upper;alloc
pub use hex;

Modules§

serde
Hex encoding with serde.
traits
Modified from hex.

Structs§

Buffer
A correctly sized stack allocation for the formatted bytes to be written into.

Enums§

FromHexError
The error type for decoding a hex string into Vec<u8> or [u8; N].

Constants§

HEX_CHARS_LOWER
The table of lowercase characters used for hex encoding.
HEX_CHARS_UPPER
The table of uppercase characters used for hex encoding.
HEX_DECODE_LUT
The lookup table of hex byte to value, used for hex decoding.
NIL
Represents an invalid value in the HEX_DECODE_LUT table.

Traits§

FromHex
Types that can be decoded from a hex string.
ToHex
Encoding values as hex string.

Functions§

check
Returns true if the input is a valid hex string and can be decoded successfully.
check_raw
Returns true if the input is a valid hex string.
const_check
Returns true if the input is a valid hex string and can be decoded successfully.
const_check_raw
Returns true if the input is a valid hex string.
const_decode_to_array
Decode a hex string into a fixed-length byte-array.
const_encode
Encodes input as a hex string into a Buffer.
decodealloc
Decodes a hex string into raw bytes.
decode_to_array
Decode a hex string into a fixed-length byte-array.
decode_to_slice
Decode a hex string into a mutable bytes slice.
encodealloc
Encodes data as a hex string using lowercase characters.
encode_prefixedalloc
Encodes data as a prefixed hex string using lowercase characters.
encode_to_slice
Encodes input as a hex string using lowercase characters into a mutable slice of bytes output.
encode_to_slice_upper
Encodes input as a hex string using uppercase characters into a mutable slice of bytes output.
encode_upperalloc
Encodes data as a hex string using uppercase characters.
encode_upper_prefixedalloc
Encodes data as a prefixed hex string using uppercase characters.