serializeBytes method

void serializeBytes(
  1. Uint8List value
)

Serializes a byte buffer.

Implementation

void serializeBytes(Uint8List value) {
  _checkState();
  final nativeBuf = calloc.allocate<Uint8>(value.length);
  try {
    nativeBuf.asTypedList(value.length).setAll(0, value);
    final rc = bindings.zd_serializer_serialize_buf(
      _loanMut().cast(),
      nativeBuf,
      value.length,
    );
    if (rc != 0) throw ZenohException('Failed to serialize bytes', rc);
  } finally {
    calloc.free(nativeBuf);
  }
}