diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 44dac461c..ef15d2cfe 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -425,6 +425,14 @@ typedef struct z_queryable_options_t { * The completeness of the Queryable. */ bool complete; +#if defined(Z_FEATURE_UNSTABLE_API) + /** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * Restricts the matching requests that will be received by this Queryable to the ones + * that have the compatible allowed_destination. + */ + enum zc_locality_t allowed_origin; +#endif } z_queryable_options_t; /** * Options passed to the `z_declare_subscriber()` function. @@ -438,7 +446,8 @@ typedef struct z_subscriber_options_t { #endif #if defined(Z_FEATURE_UNSTABLE_API) /** - * Restricts the matching publications that will be received by this Subscribers to the ones + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * Restricts the matching publications that will be received by this Subscriber to the ones * that have the compatible allowed_destination. */ enum zc_locality_t allowed_origin; diff --git a/src/queryable.rs b/src/queryable.rs index f0c3a4a84..30bc301d7 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -30,10 +30,10 @@ use crate::{ z_closure_query_call, z_closure_query_loan, z_congestion_control_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, z_moved_closure_query_t, z_moved_encoding_t, z_moved_queryable_t, z_priority_t, z_timestamp_t, - z_view_string_from_substr, z_view_string_t, + z_view_string_from_substr, z_view_string_t, zc_locality_t, }; #[cfg(feature = "unstable")] -use crate::{z_entity_global_id_t, z_moved_source_info_t}; +use crate::{z_entity_global_id_t, z_moved_source_info_t, zc_locality_default}; decl_c_type!( owned(z_owned_queryable_t, option Queryable<()>), loaned(z_loaned_queryable_t), @@ -128,12 +128,21 @@ pub extern "C" fn z_query_clone(dst: &mut MaybeUninit, this_: & pub struct z_queryable_options_t { /// The completeness of the Queryable. pub complete: bool, + #[cfg(feature = "unstable")] + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + /// Restricts the matching requests that will be received by this Queryable to the ones + /// that have the compatible allowed_destination. + pub allowed_origin: zc_locality_t, } /// Constructs the default value for `z_query_reply_options_t`. #[no_mangle] #[allow(clippy::missing_safety_doc)] pub extern "C" fn z_queryable_options_default(this_: &mut MaybeUninit) { - this_.write(z_queryable_options_t { complete: false }); + this_.write(z_queryable_options_t { + complete: false, + #[cfg(feature = "unstable")] + allowed_origin: zc_locality_default(), + }); } /// Represents the set of options that can be applied to a query reply, @@ -245,6 +254,10 @@ fn _declare_queryable_inner<'a, 'b>( let mut builder = session.declare_queryable(keyexpr); if let Some(options) = options { builder = builder.complete(options.complete); + #[cfg(feature = "unstable")] + { + builder = builder.allowed_origin(options.allowed_origin.into()) + } } let queryable = builder.callback(move |query| { let mut owned_query = Some(query); diff --git a/src/subscriber.rs b/src/subscriber.rs index 026b9f6b9..5ffe4ac5e 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -61,7 +61,8 @@ pub struct z_subscriber_options_t { /// Dummy field to avoid having fieldless struct pub _0: u8, #[cfg(feature = "unstable")] - /// Restricts the matching publications that will be received by this Subscribers to the ones + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + /// Restricts the matching publications that will be received by this Subscriber to the ones /// that have the compatible allowed_destination. pub allowed_origin: zc_locality_t, }