本项目将从零开始在 MoonBit 中实现一个符合 RFC 8949 标准的高性能 CBOR (Concise Binary Object Representation) 序列化与反序列化库。 CBOR 是一种二进制数据序列化格式,旨在保持较小消息体积的同时,具备极低的代码复杂度与高扩展性(无需进行版本协商)。它在 WebAssembly (Wasm) 生态、物联网、边缘计算以及网络协议(如 C
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
MoonBit CBOR (RFC 8949)
A CBOR (Concise Binary Object Representation, RFC 8949) serialization and deserialization library written in pure MoonBit.
This project was built for the CCF x MoonBit Open Source Competition (2026).
Core Features
CborDecodeconversions forCborValue,Bool,Int64,UInt64,String,Bytes, andDoubleviadecode_as.CborValue::Unsigned(UInt64)instead of being narrowed throughInt64.Installation
The project is verified with the MoonBit 0.10.x toolchain. CI installs the current official toolchain on every supported runner; the local acceptance environment currently uses
moonc v0.10.7.Add the package with the current MoonBit workflow:
Or add it manually to
moon.pkg:Usage Example
CLI Example
The repository includes a runnable CLI in
cmd/main:The benchmark command reports four reproducible workloads: a small map, UTF-8 text containing a non-BMP scalar, a 256-byte binary payload, and a nested array/map value. Each line includes the iteration count, encoded payload size, and elapsed time.
The application demo exercises a versioned request/response batch, a framed transport buffer, nested field queries, validation reports, recursive redaction, and bounded-ingress accounting in one reproducible command.
Performance Notes
Validation
Local acceptance loop:
CI additionally runs
moon check --target all --deny-warnandmoon test --target all --deny-warnon Linux, macOS, and Windows, and checks that formatting and generated interface steps leave a clean checkout.Windows PowerShell helper:
Repository self-check report:
The self-check reports both physical MoonBit source lines and effective production source lines (non-empty, non-comment
.mbtlines excluding tests). The local production-source gate is 3300 lines so that the project scope is backed by reusable implementation rather than documentation or generated files.Competition Notes
moon info, warning-free checks/tests for all backends, and CLI smoke tests on Linux, macOS, and Windows.docs/source-attribution.mdanddocs/acceptance-checklist.md.License
This project is licensed under Apache-2.0. See LICENSE for details.