Crate scolapasta_hex

source ·
Expand description

Functions for encoding sequences of bytes into base 16 hex encoding.

Base 16 encoding is an encoding scheme that uses a 16 character ASCII alphabet for encoding arbitrary octets.

This crate offers encoders that:

§Examples

let data = b"Artichoke Ruby";
let mut buf = String::new();
scolapasta_hex::try_encode_into(data, &mut buf)?;
assert_eq!(buf, "4172746963686f6b652052756279");

This module also exposes an iterator:

use scolapasta_hex::Hex;

let data = "Artichoke Ruby";
let iter = Hex::from(data);
assert_eq!(iter.collect::<String>(), "4172746963686f6b652052756279");

§no_std

This crate is no_std compatible when built without the std feature. This crate optionally depends on alloc when the alloc feature is enabled.

When this crate depends on alloc, it exclusively uses fallible allocation APIs. The APIs in this crate will never abort due to allocation failure or capacity overflows. Note that writers given to format_into and write_into may have abort on allocation failure behavior.

§Crate features

All features are enabled by default.

  • std - Enables a dependency on the Rust Standard Library. Activating this feature enables APIs that require std::io::Write. Activating this feature also activates the alloc feature.
  • alloc - Enables a dependency on the Rust alloc crate. Activating this feature enables APIs that require alloc::string::String.

Structs§

  • An iterator over a byte slice that returns the data as a sequence of hex encoded chars.

Functions§