Pure Pony protobuf runtime — wire codec, framing, scalar codecs, UTF-8
validation. The runtime that generated Pony code (emitted by
protoc-gen-pony) calls into.
Varint— varint encode/decode (Array[U8] iso^↔U64).ZigZag— zigzag encode/decode for signed scalars (I32/I64).Tag+TagCodec— protobuf field tag (field number + wire type).WireType— typed union (WireVarint | WireFixed64 | WireLenDelim | WireFixed32); proto2 group wire types are deliberately omitted.WireReader— cursor-style reader overArray[U8] val. Reads varints, tags, fixed-width fields, length-delimited bytes, UTF-8-validated strings; supports per-wire-type skip-unknown for forward-compat.WireWriter— accumulating writer, returns anArray[U8] iso^ondone(). Includes awrite_string_field(field_num, s)helper that internalizes proto3's "skip empty strings" rule.Scalar— paired encode/decode for all 12 protobuf scalar types (bool,int32/64,uint32/64,sint32/64,fixed32/64,sfixed32/64,float,double). UsesF32/F64.from_bits/.bitsLLVM intrinsics for lossless float round-trip.LE— little-endian byte conversion helpers, shift-based (noPlatform.bigendian()branch needed since bit shifts produce LE bytes on any host).WireError— typed-error union (WireTruncated | WireOverflow | WireBadTag | WireInvalidUtf8).
Add to your corral.json deps:
{
"locator": "github.com/TrogonStack/protobuf.pony",
"version": "0.1.0"
}Then in your Pony source:
use "protobuf"The typical caller is generated code from protoc-gen-pony. Sketch:
let writer = WireWriter
writer.write_tag(Tag(1, WireVarint))
Scalar.write_int32(writer, 42)
let bytes: Array[U8] val = recover val writer.done() end
let reader = WireReader(bytes)
match reader.read_tag()
| let t: Tag => /* dispatch on t.field_number, t.wire_type */
| let e: WireError => /* handle */
endHand-writing decoders is supported but the expected workflow is to define
your schemas in .proto, run protoc-gen-pony, and let the generated
<Msg>Codec primitives call into this runtime.
Requires Task, corral,
and ponyc.
corral fetch
task testMIT.