parser/mod.rs
1pub mod instructions;
2pub mod error;
3
4mod test_parser;
5
6pub trait InstructionTrait {
7 fn size(&self) -> usize;
8}
9
10pub fn parse(bytes: &[u8]) -> Result<instructions::Instruction, error::ParserError> {
11 if bytes.len() < 1 {
12 return Err(error::ParserError::NotEnoughBytes(bytes.len()));
13 }
14
15 let opcode = bytes[0];
16 let bytes = &bytes[1..];
17 instructions::decode(opcode, bytes)
18}
19