Trait bdk_chain::bitcoin::hashes::hex::prelude::DisplayHex

pub trait DisplayHex: Copy + IsRef {
    type Display: Display + Debug + LowerHex + UpperHex;

    // Required method
    fn as_hex(self) -> Self::Display;

    // Provided methods
    fn to_lower_hex_string(self) -> String { ... }
    fn to_upper_hex_string(self) -> String { ... }
    fn to_hex_string(self, case: Case) -> String { ... }
    fn append_hex_to_string(self, case: Case, string: &mut String) { ... }
    fn hex_reserve_suggestion(self) -> usize { ... }
}
Expand description

Extension trait for types that can be displayed as hex.

Types that have a single, obvious text representation being hex should not implement this trait and simply implement Display instead.

This trait should be generally implemented for references only. We would prefer to use GAT but that is beyond our MSRV. As a lint we require the IsRef trait which is implemented for all references.

Required Associated Types§

type Display: Display + Debug + LowerHex + UpperHex

The type providing fmt::Display implementation.

This is usually a wrapper type holding a reference to Self.

Required Methods§

fn as_hex(self) -> Self::Display

Display Self as a continuous sequence of ASCII hex chars.

Provided Methods§

fn to_lower_hex_string(self) -> String

Create a lower-hex-encoded string.

A shorthand for to_hex_string(Case::Lower), so that Case doesn’t need to be imported.

This may be faster than .display_hex().to_string() because it uses reserve_suggestion.

fn to_upper_hex_string(self) -> String

Create an upper-hex-encoded string.

A shorthand for to_hex_string(Case::Upper), so that Case doesn’t need to be imported.

This may be faster than .display_hex().to_string() because it uses reserve_suggestion.

fn to_hex_string(self, case: Case) -> String

Create a hex-encoded string.

This may be faster than .display_hex().to_string() because it uses reserve_suggestion.

fn append_hex_to_string(self, case: Case, string: &mut String)

Appends hex-encoded content to an existing String.

This may be faster than write!(string, "{:x}", self.as_hex()) because it uses hex_reserve_sugggestion.

fn hex_reserve_suggestion(self) -> usize

Hints how much bytes to reserve when creating a String.

Implementors that know the number of produced bytes upfront should override this. Defaults to 0.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<'a> DisplayHex for &'a [u8; 1]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#12}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 1] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 2]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#13}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 2] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 3]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#14}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 3] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 4]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#15}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 4] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 5]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#16}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 5] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 6]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#17}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 6] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 7]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#18}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 7] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 8]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#19}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 8] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 9]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#20}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 9] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 10]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#21}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 10] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 11]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#22}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 11] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 12]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#23}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 12] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 13]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#24}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 13] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 14]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#25}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 14] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 15]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#26}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 15] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 16]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#27}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 16] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 20]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#28}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 20] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 32]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#29}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 32] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 33]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#30}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 33] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 64]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#31}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 64] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 65]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#32}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 65] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 128]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#33}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 128] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 256]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#34}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 256] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 512]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#35}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 512] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 1024]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#36}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 1024] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 2048]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#37}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 2048] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8; 4096]

§

type Display = DisplayArray<'a, hex_conservative::::display::{impl#38}::Display::{constant#0}>

§

fn as_hex(self) -> <&'a [u8; 4096] as DisplayHex>::Display

§

impl<'a> DisplayHex for &'a [u8]

Implementors§

§

impl<'a> DisplayHex for &'a Vec<u8>