decode method
Implementation
RitoExactSourceRangeResolution decode(Uint8List bytes) {
if (bytes.length > ritoMaxWireBytes) {
throw const FormatException('RITOESR1 exceeds the byte limit.');
}
final reader = RitoBinaryReader(bytes);
reader.expectMagic(_magic, 'exact source range magic');
final version = reader.uint32('exact source range wire version');
if (version != 1) {
reader.fail('unsupported exact source range wire version: $version');
}
final declaredLength = reader.uint64('exact source range total length');
if (declaredLength != bytes.length) {
reader.fail('exact source range total length does not match input');
}
final artifactId = reader.externalId('exact source range artifact id');
final status = _status(reader);
final firstPageIndex = reader.option(
'exact source range first page',
() => reader.uint32('exact source range first page index'),
);
final selectedText = reader.string('exact source range text');
final count = reader.count('exact source rects');
final rects = <RitoExactSourceRect>[
for (var index = 0; index < count; index += 1) _rect(reader),
];
final resolution = RitoExactSourceRangeResolution(
artifactId: artifactId,
status: status,
firstPageIndex: firstPageIndex,
selectedText: selectedText,
rects: rects,
);
reader.finish('exact source range wire message');
return resolution;
}