Skip to content

Commit

Permalink
log error when keyexpr_intersect/includes fails keyexpr conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Nov 25, 2024
1 parent 65e6e13 commit 2c3df76
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions zenoh/src/api/key_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,32 +273,54 @@ impl<'a> KeyExpr<'a> {
}
}

/// Will return false in case of TryInto failure.
/// Will return false and log a error in case of TryInto failure.
#[inline]
pub(crate) fn keyexpr_intersect<'b, L, R>(left: L, right: R) -> bool
where
L: TryInto<KeyExpr<'a>>,
R: TryInto<KeyExpr<'b>>,
L::Error: std::fmt::Display,
R::Error: std::fmt::Display,
{
if let (Ok(l), Ok(r)) = (left.try_into(), right.try_into()) {
l.intersects(&r)
} else {
false
match left.try_into() {
Ok(l) => match right.try_into() {
Ok(r) => {
return l.intersects(&r);
}
Err(e) => {
tracing::error!("{e}");
}
},
Err(e) => {
tracing::error!("{e}");
}
}
return false;
}

/// Will return false in case of TryInto failure.
/// Will return false and log a error in case of TryInto failure.
#[inline]
pub(crate) fn keyexpr_include<'b, L, R>(left: L, right: R) -> bool
where
L: TryInto<KeyExpr<'a>>,
R: TryInto<KeyExpr<'b>>,
L::Error: std::fmt::Display,
R::Error: std::fmt::Display,
{
if let (Ok(l), Ok(r)) = (left.try_into(), right.try_into()) {
l.includes(&r)
} else {
false
match left.try_into() {
Ok(l) => match right.try_into() {
Ok(r) => {
return l.includes(&r);
}
Err(e) => {
tracing::error!("{e}");
}
},
Err(e) => {
tracing::error!("{e}");
}
}
return false;
}
}

Expand Down

0 comments on commit 2c3df76

Please sign in to comment.