pub trait FromHexStr: Sized {
    type Error;

    // Required method
    fn from_hex_str_no_prefix<S>(s: S) -> Result<Self, Self::Error>
       where S: AsRef<str> + Into<String>;

    // Provided method
    fn from_hex_str<S>(s: S) -> Result<Self, FromHexError<Self::Error>>
       where S: AsRef<str> + Into<String> { ... }
}
Expand description

Trait that allows types to be initialized from hex strings

Required Associated Types§

type Error

An error occurred while parsing the hex string.

Required Methods§

fn from_hex_str_no_prefix<S>(s: S) -> Result<Self, Self::Error>where S: AsRef<str> + Into<String>,

Parses provided string as hex without requiring 0x prefix.

This is not recommended for user-supplied inputs because of possible confusion with decimals. It should be only used for existing protocols which always encode values as hex without 0x prefix.

Provided Methods§

fn from_hex_str<S>(s: S) -> Result<Self, FromHexError<Self::Error>>where S: AsRef<str> + Into<String>,

Parses provided string as hex requiring 0x prefix.

This is intended for user-supplied inputs or already-existing protocols in which 0x prefix is used.

Implementors§