Trait bitcoin::string::FromHexStr
source · pub trait FromHexStr: Sized {
type Error;
// Required method
fn from_hex_str_no_prefix<S: AsRef<str> + Into<String>>(
s: S
) -> Result<Self, Self::Error>;
// Provided method
fn from_hex_str<S: AsRef<str> + Into<String>>(
s: S
) -> Result<Self, FromHexError<Self::Error>> { ... }
}
Expand description
Trait that allows types to be initialized from hex strings
Required Associated Types§
Required Methods§
sourcefn from_hex_str_no_prefix<S: AsRef<str> + Into<String>>(
s: S
) -> Result<Self, Self::Error>
fn from_hex_str_no_prefix<S: AsRef<str> + Into<String>>( 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§
sourcefn from_hex_str<S: AsRef<str> + Into<String>>(
s: S
) -> Result<Self, FromHexError<Self::Error>>
fn from_hex_str<S: AsRef<str> + Into<String>>( 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.