bdk_chain::bitcoin::hashes::hex

Module display

Expand description

Helpers for displaying bytes as hex strings.

This module provides a trait for displaying things as hex as well as an implementation for &[u8].

For arrays and slices we support padding and precision for length < 512 bytes.

§Examples

use hex_conservative::DisplayHex;

// Display as hex.
let v = vec![0xde, 0xad, 0xbe, 0xef];
assert_eq!(format!("{}", v.as_hex()), "deadbeef");

// Get the most significant bytes.
let v = vec![0x01, 0x23, 0x45, 0x67];
assert_eq!(format!("{0:.4}", v.as_hex()), "0123");

// Padding with zeros
let v = vec![0xab; 2];
assert_eq!(format!("{:0>8}", v.as_hex()), "0000abab");

Macros§

Structs§

Traits§

  • Extension trait for types that can be displayed as hex.