zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

Convenient operations for Selector

Open JEnoch opened this issue 4 years ago • 4 comments

Following discussion stated in https://github.com/eclipse-zenoh/zenoh/pull/82#issuecomment-822432476

JEnoch avatar Apr 19 '21 14:04 JEnoch

Alternatively, we can provide explicit methods to help users to modify the selector. It looks like this.

use zenoh as z;
let selector = z::selector("/a/b").add_predicate("x=3&y=4").join("c"); // "/a/b/c?x=3&y=4"

predicate is a zenoh-net abstraction that is passed with a resource key on query. I think we shall not use it with Selector. But we could add those functions:

  • with_filter()
  • with_properties()
  • with_fragment()

I don't feel join() being explicit enough. Maybe join_to_path_expr() ? But I still think if one wants to update the path expression of a Selector, he should call a function on selector.path_expr.

@jerry73204 What's your opinion ?

JEnoch avatar Apr 19 '21 14:04 JEnoch

I prefer exposing a mutable reference to underlying pathexpr, leaving it to the user. There's no need to delegate path methods on selector.

jerry73204 avatar Apr 19 '21 15:04 jerry73204

@JEnoch is this issue still open or it has been addressed by the new 0.6.0-dev API?

Mallets avatar Feb 15 '22 13:02 Mallets

This issue as not been addressed by the new API. Moreover all convenient operations that were introduced in #82 have been removed, in favor of new KeyExpr and Selector implementations that make usage of Cow<'a, str> (to avoid strings manipulations/clones) and that no longer check the string syntax (for performances reasons).

JEnoch avatar Feb 15 '22 14:02 JEnoch