undeclareKeyExpr method
Undeclares keyExpr from this session, releasing its numerical id.
🔴 The handle is consumed on every return code, errors included —
canon takes the value out before it checks anything. After this call, any
use of keyExpr throws StateError, and that includes
KeyExpr.dispose: undeclaring has already released everything.
Undeclaring on a session other than the declaring one fails with a
ZenohException carrying -128 — and still consumes the handle.
Throws ArgumentError, without consuming the handle, if keyExpr
was not obtained from declareKeyExpr: canon's undeclare takes an owned
key expression, so there is no call to make. Throws StateError, also
without consuming, if the session has been closed or the handle is
already dead.
Implementation
void undeclareKeyExpr(KeyExpr keyExpr) {
_ensureOpen();
final loanedSession =
bindings.zd_session_loan(_ptr.cast()) as Pointer<Void>;
keyExpr.undeclareFrom(loanedSession);
}