Skip to content

Commit

Permalink
add qos setters
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Feb 20, 2024
1 parent eb79877 commit 061008f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
7 changes: 7 additions & 0 deletions commons/zenoh-protocol/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ pub mod ext {
}
}

pub fn set_is_express(&mut self, is_express: bool) {
match is_express {
true => self.inner = imsg::set_flag(self.inner, Self::E_FLAG),
false => self.inner = imsg::unset_flag(self.inner, Self::E_FLAG),
}
}

pub const fn is_express(&self) -> bool {
imsg::has_flag(self.inner, Self::E_FLAG)
}
Expand Down
24 changes: 21 additions & 3 deletions zenoh/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ pub struct QoS {
}

impl QoS {
/// Get priority of the message.
/// Gets priority of the message.
pub fn priority(&self) -> Priority {
let priority = match Priority::try_from(self.inner.get_priority()) {
Ok(p) => p,
Expand All @@ -541,15 +541,33 @@ impl QoS {
priority
}

/// Get congestion control of the message.
/// Gets congestion control of the message.
pub fn congestion_control(&self) -> CongestionControl {
self.inner.get_congestion_control()
}

/// Get express flag value. If true, the message is not batched during transmission, in order to reduce latency.
/// Gets express flag value. If true, the message is not batched during transmission, in order to reduce latency.
pub fn express(&self) -> bool {
self.inner.is_express()
}

/// Sets priority value.
pub fn with_priority(mut self, priority: Priority) -> Self {
self.inner.set_priority(priority.into());
self
}

/// Sets congestion control value.
pub fn with_congestion_control(mut self, congestion_control: CongestionControl) -> Self {
self.inner.set_congestion_control(congestion_control);
self
}

/// Sets express flag vlaue.
pub fn with_express(mut self, is_express: bool) -> Self {
self.inner.set_is_express(is_express);
self
}
}

impl From<QoSType> for QoS {
Expand Down

0 comments on commit 061008f

Please sign in to comment.