askarSessionFetchKey function

Future<AskarResult<KeyEntryListHandle>> askarSessionFetchKey(
  1. SessionHandle handle,
  2. String name,
  3. bool forUpdate
)

Implementation

Future<AskarResult<KeyEntryListHandle>> askarSessionFetchKey(
  SessionHandle handle,
  String name,
  bool forUpdate,
) async {
  Pointer<Utf8> namePointer = nullptr;

  try {
    namePointer = name.toNativeUtf8();

    final callback = newCallbackWithHandle();

    final initialResult = nativeAskarSessionFetchKey(
      handle.toInt(),
      namePointer,
      boolToInt(forUpdate),
      callback.nativeCallable.nativeFunction,
      callback.id,
    );

    final completedResult = await callback.handleResult(initialResult);

    return AskarResult<KeyEntryListHandle>(
      completedResult.errorCode,
      KeyEntryListHandle(completedResult.value),
    );
  } finally {
    freePointer(namePointer);
  }
}