diff --git a/commons/zenoh-protocol/src/network/mod.rs b/commons/zenoh-protocol/src/network/mod.rs index 1be58db5cc..b2ae5deabe 100644 --- a/commons/zenoh-protocol/src/network/mod.rs +++ b/commons/zenoh-protocol/src/network/mod.rs @@ -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) } diff --git a/zenoh/src/sample.rs b/zenoh/src/sample.rs index db55bce522..6ae5f2405d 100644 --- a/zenoh/src/sample.rs +++ b/zenoh/src/sample.rs @@ -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, @@ -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 for QoS {