writeAll method

void writeAll(
  1. Uint8List data
)

Writes all bytes from data into the writer.

Throws StateError if already finished or disposed. Throws ZenohException if the native write fails.

Implementation

void writeAll(Uint8List data) {
  _checkState();
  final nativeBuf = calloc.allocate<Uint8>(data.length);
  try {
    for (var i = 0; i < data.length; i++) {
      nativeBuf[i] = data[i];
    }
    final rc = bindings.zd_bytes_writer_write_all(
      _loanMut().cast(),
      nativeBuf,
      data.length,
    );
    if (rc != 0) throw ZenohException('Failed to write bytes', rc);
  } finally {
    calloc.free(nativeBuf);
  }
}