feat(encoding): add binary package#3626
Open
bobzhang wants to merge 1 commit into
Open
Conversation
Collaborator
Coverage Report for CI Build 4483Coverage increased (+0.008%) to 94.097%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new encoding/binary package providing in-memory binary encoding helpers compatible with Go's encoding/binary: fixed-width unsigned integer byte-order helpers via an Endian enum, and unsigned/signed varint encode/decode functions with associated max-length constants and a Malformed error type.
Changes:
- New
Endianenum withdecode_uint16/32/64andencode_uint16/32/64methods supporting big and little endian. - New
encode_uvarint/uvarintandencode_varint/varinthelpers with overflow and truncation detection. - New package metadata, README examples, and comprehensive blackbox tests covering round trips, view offsets, overflow, and malformed input.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| encoding/binary/types.mbt | Defines Endian enum, Malformed suberror, and MAX_VARINT_LEN_* constants. |
| encoding/binary/endian.mbt | Implements Endian decode/encode methods using bitstring patterns for decoding. |
| encoding/binary/endian_test.mbt | Tests decode/encode, view offsets, round trips, and malformed inputs. |
| encoding/binary/varint.mbt | Implements unsigned/signed varint encode/decode with overflow checks. |
| encoding/binary/varint_test.mbt | Tests varint encode/decode, round trips, malformed cases, and Debug formatting. |
| encoding/binary/moon.pkg | Declares buffer, builtin, and debug imports, mirroring encoding/base64. |
| encoding/binary/pkg.generated.mbti | Generated package interface listing exported values, errors, and types. |
| encoding/binary/README.mbt.md | Documents byte-order and varint usage with executable mbt check examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
encoding/binaryfor checked fixed-width unsigned integer byte-order helpersScope
This intentionally covers the in-memory subset of Go-style
encoding/binary. Stream-oriented read/write APIs and reflection-based struct encoding are left out because core does not have the corresponding IO abstraction in scope for this PR.Validation
moon check encoding/binarymoon test encoding/binarymoon infomoon fmtmoon checkmoon test