Trait hex::ToHex

source ·
pub trait ToHex {
    // Required methods
    fn write_hex<W: Write>(&self, w: &mut W) -> Result;
    fn write_hex_upper<W: Write>(&self, w: &mut W) -> Result;
}
Expand description

Encoding values as hex string.

This trait is implemented for all T which implement AsRef<[u8]>. This includes String, str, Vec<u8> and [u8].

§Example

use hex::ToHex;

let mut s = String::new();
"Hello world!".write_hex(&mut s).unwrap();
println!("{}", s);

Note: instead of using this trait, you might want to use encode().

Required Methods§

source

fn write_hex<W: Write>(&self, w: &mut W) -> Result

Writes the hex string representing self into w. Lower case letters are used (e.g. f9b4ca).

source

fn write_hex_upper<W: Write>(&self, w: &mut W) -> Result

Writes the hex string representing self into w. Upper case letters are used (e.g. F9B4CA).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: AsRef<[u8]>> ToHex for T