SBE binary message codecs and MoonBit code generation with reference interoperability tests
moon update
moon test --target js --warn-list=-implicit_impl_as_method --deny-warn
moon run cmd/main --target js --warn-list=-implicit_impl_as_method -- schema interop/upstream/example-schema.xml
moon run cmd/main --target js --warn-list=-implicit_impl_as_method -- encode interop/upstream/example-schema.xml 1 examples/car.json car.bin
moon run cmd/main --target js --warn-list=-implicit_impl_as_method -- decode interop/upstream/example-schema.xml car.binmoon run cmd/main --target js --warn-list=-implicit_impl_as_method -- generate interop/upstream/example-schema.xml generated/car/messages.mbt
moon fmt generated/car
moon check --target js --warn-list=-implicit_impl_as_method --deny-warnimport {
"liyun6666/moonsbe/generated/car" @car,
}moon run tools/interop.mbtx| 接口 | 用途 |
|---|---|
| parse_schema(xml, includes=...) | 编译 XML Schema,解析类型、布局和显式提供的 XInclude |
| value_from_json(schema, template_id, source) | 根据 Schema 读取消息 JSON,保留整数精度并拒绝重复键 |
| encode(schema, template_id, value, version=...) | 编码一条包含标准 8 字节消息头的完整消息 |
| decode(schema, bytes, max_entries=...) | 解码一条已有边界的完整消息,检查长度与资源上限 |
| generate_moonbit(xml, includes=...) | 生成可编译的类型化 MoonBit 适配器 |
| compare_schemas(old, newer) | 检查此运行时下的双向版本兼容风险 |
schema SCHEMA.xml
encode SCHEMA.xml TEMPLATE_ID MESSAGE.json OUTPUT.bin
decode SCHEMA.xml INPUT.bin [OUTPUT.json]
generate SCHEMA.xml OUTPUT.mbt
compare OLD_SCHEMA.xml NEW_SCHEMA.xml
hex INPUT.binmoon fmt --check
moon check --target js --warn-list=-implicit_impl_as_method --deny-warn
moon test --target js --warn-list=-implicit_impl_as_method --deny-warn
moon test --target wasm-gc -p liyun6666/moonsbe --warn-list=-implicit_impl_as_method --deny-warn
moon run tools/interop.mbtx
moon run tools/stats.mbtxpub suberror SbeError {
InvalidSchema(String, Int)
Unsupported(String)
Truncated(Int, Int, Int)
InvalidValue(String, String)
InvalidMessage(String)
LimitExceeded(String)
} derive(Debug)pub(all) struct EvolutionReport {
old_version : Int
new_version : Int
old_reads_new : Bool
new_reads_old : Bool
differences : Array[SchemaDifference]
} derive(Debug, ToJson)Install
Download zipSBE binary message codecs and MoonBit code generation with reference interoperability tests