Skip to content

feat(encoding): add binary package#3626

Open
bobzhang wants to merge 1 commit into
mainfrom
codex/encoding-binary
Open

feat(encoding): add binary package#3626
bobzhang wants to merge 1 commit into
mainfrom
codex/encoding-binary

Conversation

@bobzhang

Copy link
Copy Markdown
Contributor

Summary

  • add encoding/binary for checked fixed-width unsigned integer byte-order helpers
  • add Go-compatible unsigned and signed varint encode/decode helpers with max length constants
  • add generated interface metadata, README examples, and blackbox tests for round trips, views, trailing bytes, overflow, and malformed input

Scope

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/binary
  • moon test encoding/binary
  • moon info
  • moon fmt
  • moon check
  • moon test

Copilot AI review requested due to automatic review settings May 24, 2026 14:19
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 4483

Coverage increased (+0.008%) to 94.097%

Details

  • Coverage increased (+0.008%) from the base build.
  • Patch coverage: 3 uncovered changes across 1 file (69 of 72 lines covered, 95.83%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
encoding/binary/endian.mbt 54 51 94.44%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15924
Covered Lines: 14984
Line Coverage: 94.1%
Coverage Strength: 206408.3 hits per line

💛 - Coveralls

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Endian enum with decode_uint16/32/64 and encode_uint16/32/64 methods supporting big and little endian.
  • New encode_uvarint/uvarint and encode_varint/varint helpers 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants