sessionless/hex/
mod.rs

1extern crate hex as hex_core;
2
3pub mod error;
4mod impls;
5
6use crate::*;
7use error::*;
8use hex_core::*;
9
10/// Type implementing this trait can be encoded into a hex string.
11pub trait IntoHex {
12    fn to_hex(&self) -> String;
13
14    fn into_hex(self) -> String
15    where
16        Self: Sized,
17    {
18        self.to_hex()
19    }
20}
21
22/// Type implementing this trait can be constructed from a hex string.
23pub trait FromHex {
24    type Error: std::error::Error;
25
26    fn from_hex(bytes: impl AsRef<[u8]>) -> Result<Self, HexError<Self::Error>>
27    where
28        Self: Sized;
29}