decodePageRecords method

RitoPageRecords decodePageRecords(
  1. Uint8List bytes
)

Decodes a RITOPGR1 message: what one page of a live artifact holds for a host.

Implementation

RitoPageRecords decodePageRecords(Uint8List bytes) {
  if (bytes.length > ritoMaxWireBytes) {
    throw const FormatException('RITOPGR1 exceeds the byte limit.');
  }
  final reader = RitoBinaryReader(bytes);
  reader.expectMagic(_pageRecordsMagic, 'page records magic');
  final version = reader.uint32('page records wire version');
  if (version != wireVersion) {
    reader.fail('unsupported page records wire version: $version');
  }
  final declaredLength = reader.uint64('page records total length');
  if (declaredLength != bytes.length) {
    reader.fail('page records total length does not match input');
  }
  final records = _pageRecords(reader, reader.externalId('artifact id'));
  reader.finish('page records wire message');
  return records;
}