Skip to main content

Crate fashex

Crate fashex 

Source
Expand description

§fashex - fast hexadecimal encoding and decoding

crates.io docs.rs license

Hexadecimal string encoding and decoding with best-effort SIMD acceleration.

§Highlights

  • Best-effort SIMD acceleration.
  • Small, focused public APIs.
  • APIs that work in const contexts.
  • Unlike crates const-hex, faster-hex, etc., this crate accepts uninitialized output buffers.

§Performance

This crate offers performance comparable to const-hex or hex-simd on x86 / x86_64 architectures.

For benchmark results, please refer to BENCHMARK.md.

§Disclaimer

Although all tests are passing and hours of fuzzing show no failures, latent bugs may still exist in the code.

  1. The SIMD-accelerated code paths for x86 / x86_64 architecture are well tested and fuzzed.
  2. The SIMD-accelerated code paths for aarch64 architecture are tested and fuzzed.
  3. The SIMD-accelerated code paths for loongarch64 architecture have not been tested or fuzzed on real hardware.

If you find any bugs, please report them.

§Acknowledgements

This crate is inspired by the following repositories:

  • const-hex, SPDX-License-Identifier: MIT OR Apache-2.0
  • hex-simd, SPDX-License-Identifier: MIT
  • faster-hex, SPDX-License-Identifier: MIT OR Apache-2.0
§License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Modules§

bufferdocsrs
Traits and implementations for buffers used by this crate.

Macros§

decode
Helper macro for decoding hexadecimal strings to byte arrays in const contexts.
encode
Helper macro for encoding byte arrays as hexadecimal strings in const contexts.

Structs§

Displayalloc
A wrapper for displaying a byte slice as a hexadecimal string.
InvalidInput
A generic error type indicating invalid input.

Constants§

HEX_CHARS_LOWER
The lowercase hexadecimal chars: "0123456789abcdef".
HEX_CHARS_UPPER
The uppercase hexadecimal chars: "0123456789ABCDEF".

Traits§

Hex
A trait for encoding / decoding a hexadecimal string from / into the raw bytes.

Functions§

decode
Decodes src (a hexadecimal string, case insensitive) into raw bytes, writes them into dst, and returns a reference to the written bytes.
decode_generic
decode(), but const-evaluable at the cost of performance.
encode
Encodes src as a hexadecimal string into dst and returns a reference to the written string.
encode_generic
encode(), but const-evaluable at the cost of performance.