Patrick Kenyon
05/03/2023, 9:10 PMfun storeProvision() = runBlocking {
fun storeProvisionCB (
callbackId: CallbackId,
errorCode: ErrorCode,
storeHandle: StoreHandle,
){
// DATA WE NEED vvvvvvvvvvvvvv
println("Callback ID: $callbackId")
println("Error code: $errorCode")
println("Store handle: $storeHandle")
// DATA WE NEED ^^^^^^^^^^^^^
}
val callback = staticCFunction(::storeProvisionCB)
val errorCode = askar_store_provision(
"<sqlite://local.db>",
null,
null,
null,
0,
callback,
21
)
println("Askar Error Code: $errorCode")
Landry Norris
05/03/2023, 9:40 PMJeff Lockhart
05/03/2023, 10:07 PMstaticCFunction
can't capture any variables. So you'll likely need to use a StableRef
reference to a global variable to write the callback state to to be able to access outside the callback afterwards. C callback functions usually provide a way to pass this user defined reference into the callback. Looks like it might be the callbackId
in your case.Patrick Kenyon
05/04/2023, 2:37 AMstaticCFunction
use suspendCoroutine
?Landry Norris
05/04/2023, 2:41 AMPatrick Kenyon
05/04/2023, 3:37 AM