Skip to content

Commit

Permalink
minor: add some comments on Decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
jetjinser committed Dec 10, 2024
1 parent 23e24d8 commit b830031
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions encoding/types.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit b830031

Please sign in to comment.