replyDel method
Sends a DELETE-kind reply to this query.
The keyExpr should match the queryable's key expression. A DELETE-kind
reply carries no payload and no encoding (mirroring z_query_reply_del),
but may carry a binary attachment and an optional timestamp. The
attachment, if provided, is consumed by this call (ownership transferred
to zenoh). The timestamp is borrowed (not consumed) and stamped onto the
reply sample.
isExpress disables batching for this reply; omitting it — or passing
null — means canon decides, which is false.
isExpress is the ONLY quality-of-service option on the reply path, and
that is deliberate. canon marks a reply's congestion control and priority
deprecated and ignored ("Reply congestion control is not supported
anymore"), so this binding does not expose them: a reply inherits the
QUERY's congestion control and priority, and nothing set here could
change that. Set them on the get or Querier instead.
Throws StateError if the query has been disposed. Throws ZenohException if the reply fails.
Implementation
void replyDel(
Object keyExpr, {
ZBytes? attachment,
Timestamp? timestamp,
bool? isExpress,
}) {
// PRE-move guards, as in replyBytes: a disposed query, a wrong-typed key
// expression and an invalid key expression string all throw before the
// attachment is moved, so on those paths the caller keeps ownership.
_ensureNotDisposed();
withLoanedKeyExpr(keyExpr, 'keyExpr', (loanedKe) {
// Timestamp is BORROWED (not moved) -- allocate an 8-byte-aligned copy
// after the pre-move guards so a pre-move throw never leaks it.
final tsPtr = timestamp != null ? _timestampToNative(timestamp) : nullptr;
try {
final rc = bindings.zd_query_reply_del(
Pointer.fromAddress(_handle).cast(),
loanedKe.cast(),
attachment != null ? attachment.nativePtr.cast() : nullptr,
tsPtr.cast(),
isExpress == null ? -1 : (isExpress ? 1 : 0),
);
// Mark the attachment ZBytes consumed UNCONDITIONALLY: once we reach
// this FFI call the pre-move guards above have passed, so
// zd_query_reply_del has moved the attachment into zenoh-c regardless
// of the return code. Marking before the rc-throw prevents a later
// use-after-move.
attachment?.markConsumed();
if (rc != 0) {
throw ZenohException('Failed to reply-del to query', rc);
}
} finally {
if (tsPtr != nullptr) {
calloc.free(tsPtr);
}
}
});
}