aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index b9f416c..c8996ee 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -159,22 +159,24 @@ impl Address for usize {
fn to_linear(&self) -> usize { *self }
}
-pub trait Decodable where Self: Sized {
- fn decode<T: IntoIterator<Item=u8>>(bytes: T) -> Option<Self>;
- fn decode_into<T: IntoIterator<Item=u8>>(&mut self, bytes: T) -> Option<()>;
+pub trait Decoder<Inst> where Inst: Sized {
+ fn decode<T: IntoIterator<Item=u8>>(&self, bytes: T) -> Option<Inst>;
+ fn decode_into<T: IntoIterator<Item=u8>>(&self, &mut Inst, bytes: T) -> Option<()>;
}
#[cfg(feature="use-serde")]
pub trait Arch {
type Address: Address + Debug + Hash + PartialEq + Eq + Serialize + for<'de> Deserialize<'de>;
- type Instruction: Decodable + LengthedInstruction<Unit=Self::Address> + Debug;
+ type Instruction: LengthedInstruction<Unit=Self::Address> + Debug;
+ type Decoder: Decoder<Self::Instruction> + Default;
type Operand;
}
#[cfg(not(feature="use-serde"))]
pub trait Arch {
type Address: Address + Debug + Hash + PartialEq + Eq;
- type Instruction: Decodable + LengthedInstruction<Unit=Self::Address> + Debug;
+ type Instruction: LengthedInstruction<Unit=Self::Address> + Debug;
+ type Decoder: Decoder<Self::Instruction> + Default;
type Operand;
}