Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt accessor pattern for Selector #1431

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions zenoh/src/api/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,25 @@ use super::{key_expr::KeyExpr, queryable::Query};
/// this parameter must be readable by the [Zenoh Time DSL](zenoh_util::time_range::TimeRange) for the value to be considered valid.
/// - **`[unstable]`** `_anyke`: used in queries to express interest in replies coming from any key expression. By default, only replies
/// whose key expression match query's key expression are accepted. `_anyke` disables the query-reply key expression matching check.
#[non_exhaustive]
#[derive(Clone, PartialEq, Eq)]
pub struct Selector<'a> {
/// The part of this selector identifying which keys should be part of the selection.
pub key_expr: Cow<'a, KeyExpr<'a>>,
pub(crate) key_expr: Cow<'a, KeyExpr<'a>>,
/// the part of this selector identifying which values should be part of the selection.
pub parameters: Cow<'a, Parameters<'a>>,
pub(crate) parameters: Cow<'a, Parameters<'a>>,
}

impl<'a> Selector<'a> {
/// Get the [`KeyExpr`] of this selector.
pub fn key_expr(&'a self) -> &'a KeyExpr<'a> {
&self.key_expr
}

/// Get the [`KeyExpr`] of this selector.
pub fn parameters(&'a self) -> &'a Parameters<'a> {
&self.parameters
}

/// Builds a new selector which owns keyexpr and parameters
pub fn owned<K, P>(key_expr: K, parameters: P) -> Self
where
Expand Down
Loading