From ad62658980d41dc1f5d1bb51eff0b2e711737360 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Wed, 6 Apr 2022 22:47:38 -0400 Subject: [PATCH] Rustdocs --- src/run/parse.rs | 4 ++++ src/run/parse/load8/immediate.rs | 1 + src/run/parse/load8/transfer.rs | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/run/parse.rs b/src/run/parse.rs index 87ead09..93e5c02 100644 --- a/src/run/parse.rs +++ b/src/run/parse.rs @@ -19,9 +19,13 @@ pub(super) type ParseResult<'a> = Result<(RunnableInstruction, &'a [u8]), Error> /// `OpcodeParser` takes input data, parses out an opcode (and its associated arguments) if it can, and returns /// the remaining data after reading it. trait OpcodeParser { + /// Parse an opcode and all of its data from the given data buffer. Returns either an error, or + /// The parsed instruction, and a slice of all the data after the instruction fn parse_opcode(data: &[u8]) -> ParseResult; } +/// `next_instruction` will parse the next instruction from the given data stream. Returns either an error, +/// or the parsed instruction, and a slice of all the data after the instruction pub fn next_instruction(data: &[u8]) -> ParseResult { let parse_funcs = &[ load8::immediate::Immediate8BitLoadParser::parse_opcode, diff --git a/src/run/parse/load8/immediate.rs b/src/run/parse/load8/immediate.rs index 5e4ef8d..097e46f 100644 --- a/src/run/parse/load8/immediate.rs +++ b/src/run/parse/load8/immediate.rs @@ -9,6 +9,7 @@ use crate::run::{ pub struct Immediate8BitLoadParser; impl OpcodeParser for Immediate8BitLoadParser { + /// Parses an opcode that will transfer an immediate 8 bit value into a single register. fn parse_opcode(data: &[u8]) -> ParseResult { let opcode = parse::get_opcode_from_data(data)?; diff --git a/src/run/parse/load8/transfer.rs b/src/run/parse/load8/transfer.rs index 24d2bf5..84604fa 100644 --- a/src/run/parse/load8/transfer.rs +++ b/src/run/parse/load8/transfer.rs @@ -22,7 +22,7 @@ macro_rules! match_opcode { } impl OpcodeParser for Between8BitRegisterParser { - #[allow(clippy::too_many_lines)] + /// Parses an opcode that transfers an 8bit values between single registers. fn parse_opcode(data: &[u8]) -> ParseResult { let opcode = parse::get_opcode_from_data(data)?; match_opcode!(