ball_file library

Self-describing ball-file envelope.

A ball file on disk (.ball.json or .ball.bin) is a serialized google.protobuf.Any wrapping exactly one top-level message — today a Program or a Module. Readers never guess the contained type: it is carried explicitly by the Any type URL, which in proto3 JSON is the @type field. New top-level types can be added without changing any reader's discrimination logic.

Binary form uses the real google.protobuf.Any (type_url + value bytes). JSON form is the proto3-JSON representation of an Any: {"@type": "type.googleapis.com/ball.v1.Program", <message fields…>} — so it round-trips through the message's own proto3-JSON codec plus the one @type key, with no type registry required.

Classes

BallFile
The decoded contents of a ball file: exactly one top-level message.
BallModuleFile
A ball file wrapping a Module.
BallProgramFile
A ball file wrapping a Program.

Constants

moduleTypeUrl → const String
programTypeUrl → const String

Functions

decodeBallFileBinary(List<int> bytes) → BallFile
Decodes a binary ball file (serialized google.protobuf.Any).
decodeBallFileJson(Object? json) → BallFile
Decodes a proto3-JSON ball file (an Any with an @type field).
decodeModuleBinary(List<int> bytes) → Module
Decodes a Module from a binary ball file, or throws if it wraps a Program.
decodeModuleJson(Object? json) → Module
Decodes a Module from a ball file, or throws if it wraps a Program.
decodeProgramBinary(List<int> bytes) → Program
Decodes a Program from a binary ball file, or throws if it wraps a Module.
decodeProgramJson(Object? json) → Program
Decodes a Program from a ball file, or throws if it wraps a Module.
encodeBallFileBinary(GeneratedMessage message) → Uint8List
Encodes a Program or Module as a binary ball file (a serialized google.protobuf.Any).
encodeBallFileJson(GeneratedMessage message) → Map<String, dynamic>
Encodes a Program or Module as a proto3-JSON ball file: the message's own proto3 JSON with the Any @type key prepended.

Exceptions / Errors

BallFileFormatException
Thrown when a ball file is not a recognized self-describing envelope.