From b830031f43c5d9b9729737c5f7ca51387318d69f Mon Sep 17 00:00:00 2001 From: Jinser Kafka Date: Tue, 10 Dec 2024 14:19:26 +0800 Subject: [PATCH] minor: add some comments on Decoder --- encoding/types.mbt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/encoding/types.mbt b/encoding/types.mbt index ed0684d..907a3fb 100644 --- a/encoding/types.mbt +++ b/encoding/types.mbt @@ -27,12 +27,32 @@ pub(all) enum Encoding { ///| priv struct Decoder { + // Input bytes + // Stores the input bytes that need to be decoded. + // The primary data source from which characters are read and decoded. mut i : Bytes + // Input position + // Keeps track of the current position within the input bytes `i`. + // Indicates the next byte (starting point) to read from `i` during the decoding process mut i_pos : Int + // Input maximum + // Indicates the index of the last byte of the input bytes `i`. + // Helps bounds checking and limits how far the decoding process should go, + // ensuring that decoding does not go beyond the provided input length. mut i_max : Int + // Temporary bytes + // Used to temporarily store bytes that are read in parts + // (which might happen for multi-byte encoded characters). t : Bytes + // Temporary Length + // Tracks how many bytes currently reside in the temporary bytes `t`. mut t_len : Int + // Temporary Need + // The number of bytes still needed to complete the character code currently being processed. mut t_need : Int + // Continuation + // + // Called with a `Decoder` state. mut k : Cont }