parseChunk function
Implementation
FourdgsChunkBody parseChunk(Uint8List content) {
final c = FourdgsCursor(content);
final intervalAt = c.pos;
final t0 = c.f64();
final t1 = c.f64();
refuseUnusableInterval(t0, t1, intervalAt, 'Chunk');
final head = FourdgsChunkHeader(
t0: t0,
t1: t1,
level: c.u32(),
count: c.u32(),
compression: c.string(),
uncompressedSize: c.u64(),
);
final length = c.u64();
final records = c.take(length);
if (head.compression.isEmpty && head.uncompressedSize != records.length) {
throw FourdgsMalformedFile(
'the uncompressed Chunk declares ${head.uncompressedSize} record bytes '
'but carries ${records.length}',
);
}
return FourdgsChunkBody(head, records, streamsOffset: c.pos - length);
}