Trait ToHex

Source
pub trait ToHex {
    // Required methods
    fn to_hex(&self) -> String;
    fn to_hex_with_prefix(&self) -> String;
}
Expand description

This trait represents a value that can be converted to a string of hexadecimal digits which represent the raw byte encoding of that value.

This trait should only be implemented for types which can be decoded from the resulting string of hexadecimal digits. It is not a strict requirement, but one that ensures that the implementation is sane.

Required Methods§

Source

fn to_hex(&self) -> String

Convert this value to a String containing the hexadecimal digits that correspond to the byte representation of this value.

The resulting string should not have a leading 0x prefix. Use ToHex::to_hex_with_prefix if the prefix is needed.

Source

fn to_hex_with_prefix(&self) -> String

Same as ToHex::to_hex, but ensures the output contains a leading 0x prefix.

Implementations on Foreign Types§

Source§

impl ToHex for [u8]

Implementors§

Source§

impl<'a> ToHex for DisplayHex<'a>