Trait FromHexStr
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
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>
fn from_hex_str_no_prefix<S>(s: S) -> Result<Self, Self::Error>
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>>
fn from_hex_str<S>(s: S) -> Result<Self, FromHexError<Self::Error>>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.