hi I have the following struct from kafka c lib ``...
# kotlin-native
n
hi I have the following struct from kafka c lib
Copy code
typedef struct rd_kafka_message_s {
      ...
	void   *payload;           /**< Producer: original message payload.
				    * Consumer: Depends on the value of \c err :
				    * - \c err==0: Message payload.
				    * - \c err!=0: Error string */
	size_t  len;               /**< Depends on the value of \c err :
				    * - \c err==0: Message payload length
				    * - \c err!=0: Error string length */
	...
} rd_kafka_message_t;
I am struggling to figure out how to read the payload to a bytearray from Kotlin the interop binding gives me
Copy code
public final var payload: kotlinx.cinterop.COpaquePointer? /* = kotlinx.cinterop.CPointer<out kotlinx.cinterop.CPointed>? */

public final var len: platform.posix.size_t /* = kotlin.ULong */
d
You can cast that payload to
CPointer<Byte>
. Then index it like you would an array.
n
by cast do you mean
.reinterpret<ByteVar>()
?
d
Yes