setValueWithPriority method

Future<void> setValueWithPriority(
  1. Object? value,
  2. Object? priority
)

Writes value with priority on disconnect, in one operation.

Implementation

Future<void> setValueWithPriority(Object? value, Object? priority) {
  final v = encodeVariant(value);
  final pr = encodeVariant(priority);
  final p = path.toNativeUtf8();
  final vb = calloc<Uint8>(v.isEmpty ? 1 : v.length);
  final pb = calloc<Uint8>(pr.isEmpty ? 1 : pr.length);
  if (v.isNotEmpty) vb.asTypedList(v.length).setAll(0, v);
  if (pr.isNotEmpty) pb.asTypedList(pr.length).setAll(0, pr);
  return _awaitDbOutcome(
    (port) => fdbDbOnDisconnectSetWithPriority(
      p.cast(),
      vb,
      v.length,
      pb,
      pr.length,
      port,
    ),
    'onDisconnect.setWithPriority',
  ).whenComplete(() {
    calloc
      ..free(p)
      ..free(vb)
      ..free(pb);
  });
}