mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/pv_core: Add decode_hex
It's uncommon and prone to error to silently stop decoding/parsing a hex-string if there is an invalid character. Therefore, add a new function `decode_hex` which fixes this behavior and use it in the code. Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
a4a29d1e05
commit
8da2f44ae2
@@ -68,6 +68,12 @@ pub enum Error {
|
||||
Io(#[from] std::io::Error),
|
||||
#[error(transparent)]
|
||||
ParseInt(#[from] std::num::ParseIntError),
|
||||
|
||||
#[error("Cannot decode hex string: Size {0} is not a multiple of two")]
|
||||
InvHexStringSize(usize),
|
||||
|
||||
#[error("Cannot decode hex string")]
|
||||
InvHexStringChar { source: std::num::ParseIntError },
|
||||
}
|
||||
|
||||
/// Error cases for I/O operations
|
||||
|
||||
Reference in New Issue
Block a user