easy_hex/from_str.rs
1use std::str::FromStr;
2
3use crate::{decode_into, FromHexError, Hex, UpperHex};
4
5impl<T> FromStr for Hex<T>
6where
7 T: for<'a> TryFrom<&'a [u8]>,
8{
9 type Err = FromHexError;
10
11 fn from_str(s: &str) -> Result<Self, Self::Err> {
12 decode_into(s).map(Hex)
13 }
14}
15
16impl<T> FromStr for UpperHex<T>
17where
18 T: for<'a> TryFrom<&'a [u8]>,
19{
20 type Err = FromHexError;
21
22 fn from_str(s: &str) -> Result<Self, Self::Err> {
23 decode_into(s).map(UpperHex)
24 }
25}