diff options
author | iximeow <me@iximeow.net> | 2020-01-03 19:17:53 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2020-01-12 17:08:59 -0800 |
commit | d03c04b89e7ffb3cce9f830e873e8b50e6b5fd9e (patch) | |
tree | daf45089626f95fce2debfb37ca2bd0121fba57f /src/display.rs | |
parent | 693e21378ecec332254d48642cd7b751cabeb6da (diff) |
match changes in arch to have Resulty decode, instead of Option
Diffstat (limited to 'src/display.rs')
-rw-r--r-- | src/display.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/display.rs b/src/display.rs index 4593f20..7836d10 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,6 +1,6 @@ -use ::{MSP430, Operand, Opcode, Instruction, Width}; +use ::{MSP430, Operand, Opcode, Instruction, Width, DecodeError}; -use std::fmt::{Display, Formatter}; +use std::fmt::{self, Display, Formatter}; use std; use yaxpeax_arch::{Arch, Colorize, ColorSettings, ShowContextual}; @@ -12,6 +12,16 @@ impl Display for Instruction { } } +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"), + } + } +} + impl <T: std::fmt::Write> ShowContextual<<MSP430 as Arch>::Address, [Option<String>], T> for Instruction { fn contextualize(&self, _colors: Option<&ColorSettings>, _address: <MSP430 as Arch>::Address, _context: Option<&[Option<String>]>, out: &mut T) -> std::fmt::Result { write!(out, "{}", self.opcode)?; |