diff --git a/zenoh/src/query.rs b/zenoh/src/query.rs index c4f3fb35e9..cc70021013 100644 --- a/zenoh/src/query.rs +++ b/zenoh/src/query.rs @@ -297,6 +297,7 @@ impl<'a, 'b, Handler> GetBuilder<'a, 'b, Handler> { } /// Set query value. + /// The existing value and encoding will be overwritten. #[inline] pub fn with_value(mut self, value: IntoValue) -> Self where @@ -306,6 +307,20 @@ impl<'a, 'b, Handler> GetBuilder<'a, 'b, Handler> { self } + /// Set the encoding of the existing query value. + /// The empty value will be created if value is not set. + #[inline] + pub fn encoding(mut self, encoding: IntoEncoding) -> Self + where + IntoEncoding: Into, + { + match self.value { + Some(ref mut value) => value.encoding = encoding.into(), + None => self.value = Some(Value::empty().encoding(encoding.into())), + } + self + } + #[zenoh_macros::unstable] pub fn with_attachment(mut self, attachment: Attachment) -> Self { self.attachment = Some(attachment);