omnibuf 0.1.0
omnibuf: ^0.1.0 copied to clipboard
OmniBuf v0.1 binary wire format for Dart: Prefix-Varint codec, 16 explicit wire types, Field #0 self-describing metadata, lazy Opaque views with in-place wire splicing, package:protobuf integration, d [...]
OmniBuf for Dart #
Dart 3 implementation of the OmniBuf v0.1 binary wire format.
Features #
- Core v0.1 Wire Codec: All 16 wire types (
WireUintthroughWireExtended), 1/2/4/9-byte Prefix-Varints with non-minimal decoding and reserved-prefix rejection, 64-bit ZigZag + 32-bit narrowing, strict UTF-8 validation,O(1)field skipping, and unsigned UTF-8 byte-order deterministic map sorting. - Field #0 Self-Describing Metadata: Optional
SchemaMetaembedding, recursive child propagation, empty-string name clearing, and multi-block merge support. - Tier 1 (
protoc-gen-omnibuf-dart): Generates idiomatic Dart 3 message classes, single-passUint8List/ByteDataencoders with 4-byte container pre-sizing, and lazyOpaqueviews for zero-decode field access and in-place wire splicing. - Tier 2 (
package:protobuf):ProtobufOmniBufCodecserializes and deserializes standardGeneratedMessageinstances directly viaBuilderInfo. - Tier 3 (
OmniBufSchema): Declarative and@OmniBufMessage/@OmniBufFieldclass schema codec with replace and merge decoding modes. - Tier 4 (
decodeBlind/decodeBlindJson): Schema-less packet inspection resolving Field #0 names orfield_<N>fallback keys.
Installation #
Add omnibuf to your pubspec.yaml:
dependencies:
omnibuf: ^0.1.0
Quick Start #
import 'package:omnibuf/omnibuf.dart';
import 'package:omnibuf/src/generated/omnibuf/bench/peer.omnibuf.dart';
void main() {
final msg = PeerUpdate(
asn: 64512,
routerId: 'edge-rtr-fra01',
active: true,
location: Location(city: 'Frankfurt', rack: 42),
sequence: 100,
);
// Single-pass binary encode
final bytes = msg.encode();
// Zero-decode nested field read via Opaque view
final view = OpaquePeerUpdate(bytes);
print(view.locationOpaque?.city); // Frankfurt
// In-place wire splice (untouched fields copy verbatim)
view.sequence = view.sequence + 1;
final patched = view.marshalAppend();
// Schema-less inspection
print(decodeBlindJson(patched));
}
Development & Verification #
just install # dart pub get
just proto # buf lint + regenerate Tier 1 Dart code
just build # AOT-compile plugin, conformance adapter, and benchmarks
just test # dart test
just conformance # Run cross-language conformance-runner (992/992 across all 4 tiers)
just bench # Run AOT PeerUpdate benchmarks -> testdata/benchmarks.json
just ci # fmt-check + lint + build + test + conformance
License #
Apache-2.0. See LICENSE.