write method
Writes data, completing once the transport accepted all of it.
Implementation
@override
Future<void> write(List<int> data) async {
if (data.isEmpty) return;
final pointer = calloc<Uint8>(data.length);
try {
pointer.asTypedList(data.length).setAll(0, data);
final event = await nativeRuntime.oneShot(
'wt_send_stream_write_all',
(opId) =>
b.wt_send_stream_write_all(_handle, pointer, data.length, opId),
);
if (!event.isOk) throw event.exception('write');
} finally {
// The native side copies the payload before the call returns.
calloc.free(pointer);
}
}