Skip to content

Commit

Permalink
QoS.from_or_default to replace only priority value by default one in …
Browse files Browse the repository at this point in the history
…case of failure
  • Loading branch information
DenisBiryukov91 committed Feb 13, 2024
1 parent b90fc73 commit 3028518
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions zenoh/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,19 @@ pub struct QoS {
}

impl QoS {
/// Helper function to fallback to default QoS value and log a error in case of conversion failure
/// Helper function to fallback to QoS with default priortiy value, in case we fail to extract it
pub(crate) fn from_or_default(ext: QoSType) -> QoS {
match QoS::try_from(ext) {
Ok(qos) => return qos,
let priority = match Priority::try_from(ext.get_priority()) {
Ok(p) => p,
Err(e) => {
log::error!("Failed to convert: {}", e.to_string());
QoS::default()
log::error!("Failed to convert priority: {}", e.to_string());
Priority::default()
}
};
QoS {
priority,
congestion_control: ext.get_congestion_control(),
express: ext.is_express(),
}
}
}
Expand Down

0 comments on commit 3028518

Please sign in to comment.