diff options
| author | iximeow <me@iximeow.net> | 2019-11-28 02:19:43 -0800 | 
|---|---|---|
| committer | iximeow <me@iximeow.net> | 2020-01-12 16:26:39 -0800 | 
| commit | c5021c15a8a16d789711c8043562b5f52f607642 (patch) | |
| tree | b4a4f36a0bdbd76f33a05e97effd018dca58c3dd /src | |
| parent | 312a5a75025b5cb01b9b626822cab3a65e23fafc (diff) | |
decoders are stateful, so decode functions should take them as a parameter
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 12 | 
1 files changed, 7 insertions, 5 deletions
| @@ -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;  } | 
