decode static method

Implementation

static CompressableQueryUpdate decode(BsatnDecoder decoder) {
  final tag = decoder.readU8();

  if (tag == 0) {
    return CompressableQueryUpdate(QueryUpdate.decode(decoder));
  } else if (tag == 1) {
    final compressed = decoder.readByteArray();
    final decompressed = Uint8List.fromList(brotli.decode(compressed));
    return CompressableQueryUpdate(
      QueryUpdate.decode(BsatnDecoder(decompressed)),
    );
  } else if (tag == 2) {
    final compressed = decoder.readByteArray();
    final decompressed = Uint8List.fromList(gzip.decode(compressed));
    return CompressableQueryUpdate(
      QueryUpdate.decode(BsatnDecoder(decompressed)),
    );
  }

  throw ArgumentError('Unknown CompressableQueryUpdate tag: $tag');
}