join method

KeyExpr join(
  1. Object other
)

Returns a new key expression joining this one to other with a /.

KeyExpr('FOO').join('BAR') is FOO/BAR. The separator is inserted by canon, not by this binding.

other is a String or a KeyExpr; a KeyExpr argument is loaned, not consumed, and remains the caller's to dispose. Unlike concat's right operand — a raw byte range — a join's right operand must itself be a valid key expression, which is what makes the union the natural shape here.

The result is an owned key expression the caller must dispose.

Throws ArgumentError if other is neither a String nor a KeyExpr. Throws ZenohException if the join is invalid. Throws StateError if either key expression is no longer alive.

Implementation

KeyExpr join(Object other) {
  final loaned = loanedKeyExpr;
  return withLoanedKeyExpr(other, 'other', (loanedRight) {
    final slot = calloc.allocate<Void>(bindings.zd_keyexpr_sizeof());
    final rc = bindings.zd_keyexpr_join(
      slot.cast(),
      loaned.cast(),
      loanedRight.cast(),
    );
    if (rc != 0) {
      calloc.free(slot);
      throw ZenohException('Failed to join key expression', rc);
    }
    return KeyExpr._owned(slot);
  });
}