Skip to content

Commit

Permalink
Add payload and encoding accessors for Query
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Apr 5, 2024
1 parent eb1a80a commit a43e451
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion zenoh/src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::Id;
use crate::SessionRef;
use crate::Undeclarable;
#[cfg(feature = "unstable")]
use crate::{query::ReplyKeyExpr, sample::Attachment, sample::builder::SampleBuilder};
use crate::{query::ReplyKeyExpr, sample::builder::SampleBuilder, sample::Attachment};
use std::fmt;
use std::future::Ready;
use std::ops::Deref;
Expand Down Expand Up @@ -97,6 +97,18 @@ impl Query {
self.inner.value.as_ref()
}

/// This Query's payload.
#[inline(always)]
pub fn payload(&self) -> Option<&Payload> {
self.inner.value.as_ref().map(|v| &v.payload)
}

/// This Query's encoding.
#[inline(always)]
pub fn encoding(&self) -> Option<&Encoding> {
self.inner.value.as_ref().map(|v| &v.encoding)
}

#[zenoh_macros::unstable]
pub fn attachment(&self) -> Option<&Attachment> {
self.inner.attachment.as_ref()
Expand Down

0 comments on commit a43e451

Please sign in to comment.