readAllNative method
Reads the whole file into a pooled native buffer.
The caller owns the result and must dispose/release it.
Implementation
Future<NativeBuffer> readAllNative({NativeBufferPool? pool}) async {
final length = await this.length;
final buffer = pool?.acquire(length) ?? NativeBuffer.allocate(length);
try {
final n = await readIntoNative(0, buffer);
if (n != length) throw StateError('short native read: $n of $length');
return buffer;
} catch (_) {
pool?.release(buffer);
rethrow;
}
}