decodeBallFileBinary function
Decodes a binary ball file (serialized google.protobuf.Any).
Implementation
BallFile decodeBallFileBinary(List<int> bytes) {
final any = Any.fromBuffer(bytes);
if (_isProgramUrl(any.typeUrl)) {
final p = Program();
any.unpackInto(p);
return BallProgramFile(p);
}
if (_isModuleUrl(any.typeUrl)) {
final m = Module();
any.unpackInto(m);
return BallModuleFile(m);
}
throw BallFileFormatException('unknown ball file type URL: "${any.typeUrl}"');
}