readExact method

Future<Uint8List> readExact(
  1. int length
)

Reads exactly length bytes (native only).

Implementation

Future<Uint8List> readExact(int length) async {
  final buffer = NativeBuffer(length);
  final event = await nativeRuntime.oneShot(
    'wt_recv_stream_read_exact',
    (opId) => b.wt_recv_stream_read_exact(_handle, buffer.data, length, opId),
  );
  if (!event.isOk) {
    buffer.free();
    throw event.exception('readExact');
  }
  return adoptBuffer(buffer.handle, length);
}