aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2021-07-03 22:13:29 -0700
committeriximeow <me@iximeow.net>2021-07-03 22:13:29 -0700
commit017e1e95067406cb7de024014750527b99188330 (patch)
tree445bd3daf528cd273a653e9ae9521a493a90bc65
parente3203b6ba52cdc620526407c02eb834496ec75cc (diff)
update DecodeError impls
-rw-r--r--src/long_mode/mod.rs20
-rw-r--r--src/protected_mode/mod.rs20
2 files changed, 24 insertions, 16 deletions
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index 64b8a4d..886dd1c 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -13,18 +13,12 @@ use core::cmp::PartialEq;
use core::hint::unreachable_unchecked;
use yaxpeax_arch::{AddressDiff, Decoder, Reader, LengthedInstruction};
+use yaxpeax_arch::{DecodeError as ArchDecodeError};
use core::fmt;
impl fmt::Display for DecodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- DecodeError::ExhaustedInput => { write!(f, "exhausted input") },
- DecodeError::InvalidOpcode => { write!(f, "invalid opcode") },
- DecodeError::InvalidOperand => { write!(f, "invalid operand") },
- DecodeError::InvalidPrefixes => { write!(f, "invalid prefixes") },
- DecodeError::TooLong => { write!(f, "too long") },
- DecodeError::IncompleteDecoder => { write!(f, "the decoder is incomplete") },
- }
+ f.write_str(self.description())
}
}
@@ -2727,6 +2721,16 @@ impl yaxpeax_arch::DecodeError for DecodeError {
fn data_exhausted(&self) -> bool { self == &DecodeError::ExhaustedInput }
fn bad_opcode(&self) -> bool { self == &DecodeError::InvalidOpcode }
fn bad_operand(&self) -> bool { self == &DecodeError::InvalidOperand }
+ fn description(&self) -> &'static str {
+ match self {
+ DecodeError::ExhaustedInput => { "exhausted input" },
+ DecodeError::InvalidOpcode => { "invalid opcode" },
+ DecodeError::InvalidOperand => { "invalid operand" },
+ DecodeError::InvalidPrefixes => { "invalid prefixes" },
+ DecodeError::TooLong => { "too long" },
+ DecodeError::IncompleteDecoder => { "the decoder is incomplete" },
+ }
+ }
}
#[allow(non_camel_case_types)]
diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs
index 166358b..cacfcbb 100644
--- a/src/protected_mode/mod.rs
+++ b/src/protected_mode/mod.rs
@@ -13,18 +13,12 @@ use core::cmp::PartialEq;
use core::hint::unreachable_unchecked;
use yaxpeax_arch::{AddressDiff, Decoder, Reader, LengthedInstruction};
+use yaxpeax_arch::{DecodeError as ArchDecodeError};
use core::fmt;
impl fmt::Display for DecodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- DecodeError::ExhaustedInput => { write!(f, "exhausted input") },
- DecodeError::InvalidOpcode => { write!(f, "invalid opcode") },
- DecodeError::InvalidOperand => { write!(f, "invalid operand") },
- DecodeError::InvalidPrefixes => { write!(f, "invalid prefixes") },
- DecodeError::TooLong => { write!(f, "too long") },
- DecodeError::IncompleteDecoder => { write!(f, "the decoder is incomplete") },
- }
+ f.write_str(self.description())
}
}
@@ -2581,6 +2575,16 @@ impl yaxpeax_arch::DecodeError for DecodeError {
fn data_exhausted(&self) -> bool { self == &DecodeError::ExhaustedInput }
fn bad_opcode(&self) -> bool { self == &DecodeError::InvalidOpcode }
fn bad_operand(&self) -> bool { self == &DecodeError::InvalidOperand }
+ fn description(&self) -> &'static str {
+ match self {
+ DecodeError::ExhaustedInput => { "exhausted input" },
+ DecodeError::InvalidOpcode => { "invalid opcode" },
+ DecodeError::InvalidOperand => { "invalid operand" },
+ DecodeError::InvalidPrefixes => { "invalid prefixes" },
+ DecodeError::TooLong => { "too long" },
+ DecodeError::IncompleteDecoder => { "the decoder is incomplete" },
+ }
+ }
}
#[allow(non_camel_case_types)]