A pure-runtime Protocol Buffers wire format encoder/decoder and proto3 subset parser in MoonBit
type Decodertype Encoderpub struct ProtoField {
name : String
number : UInt
field_type : FieldType
label : FieldLabel
} derive(Eq, Debug)pub struct ProtoFile {
messages : Array[ProtoMessage]
enums : Array[ProtoEnum]
services : Array[ProtoService]
} derive(Eq, Debug)pub struct ProtoMessage {
name : String
fields : Array[ProtoField]
oneofs : Array[ProtoOneof]
nested_messages : Array[ProtoMessage]
nested_enums : Array[ProtoEnum]
} derive(Eq, Debug)fn decode_sint32(bytes : Bytes, pos : Int) -> (Int, Int)?fn decode_sint64(bytes : Bytes, pos : Int) -> (Int64, Int)?fn decode_varint(bytes : Bytes, pos : Int) -> (UInt64, Int)?fn decode_zigzag32(value : UInt) -> Intfn decode_zigzag64(value : UInt64) -> Int64fn encode_zigzag32(value : Int) -> UIntfn encode_zigzag64(value : Int64) -> UInt64fn make_tag(field_number : UInt, wire_type : UInt) -> UIntfn read_fixed32(bytes : Bytes, pos : Int) -> (UInt, Int)?fn read_fixed64(bytes : Bytes, pos : Int) -> (UInt64, Int)?fn split_tag(tag : UInt) -> (UInt, UInt)A pure-runtime Protocol Buffers wire format encoder/decoder and proto3 subset parser in MoonBit