Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add accept_replies to z_get_options_t and use it in ze_querying_subscriber_get #620

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ typedef struct z_get_options_t {
struct z_value_t value;
struct z_attachment_t attachment;
uint64_t timeout_ms;
enum zcu_reply_keyexpr_t accept_replies;
} z_get_options_t;
/**
* An borrowed array of borrowed, zenoh allocated, NULL terminated strings.
Expand Down
6 changes: 4 additions & 2 deletions src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use crate::attachment::{
};
use crate::{
impl_guarded_transmute, z_bytes_t, z_closure_reply_call, z_encoding_default, z_encoding_t,
z_keyexpr_t, z_owned_closure_reply_t, z_sample_t, z_session_t, GuardedTransmute,
LOG_INVALID_SESSION,
z_keyexpr_t, z_owned_closure_reply_t, z_sample_t, z_session_t, zcu_reply_keyexpr_default,
zcu_reply_keyexpr_t, GuardedTransmute, LOG_INVALID_SESSION,
};

type ReplyInner = Option<Reply>;
Expand Down Expand Up @@ -168,6 +168,7 @@ pub struct z_get_options_t {
pub value: z_value_t,
pub attachment: z_attachment_t,
pub timeout_ms: u64,
pub accept_replies: zcu_reply_keyexpr_t,
}
#[no_mangle]
pub extern "C" fn z_get_options_default() -> z_get_options_t {
Expand All @@ -182,6 +183,7 @@ pub extern "C" fn z_get_options_default() -> z_get_options_t {
}
},
attachment: z_attachment_null(),
accept_replies: zcu_reply_keyexpr_default(),
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/querying_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ type FetchingSubscriber = Option<Box<FetchingSubscriberWrapper>>;

/// An owned zenoh querying subscriber. Destroying the subscriber cancels the subscription.
///
/// Like most `ze_owned_X_t` types, you may obtain an instance of `z_X_t` by loaning it using `z_X_loan(&val)`.
/// The `z_loan(val)` macro, available if your compiler supports C11's `_Generic`, is equivalent to writing `z_X_loan(&val)`.
/// Like most `ze_owned_X_t` types, you may obtain an instance of `z_X_t` by loaning it using `z_X_loan(&val)`.
/// The `z_loan(val)` macro, available if your compiler supports C11's `_Generic`, is equivalent to writing `z_X_loan(&val)`.
///
/// Like all `ze_owned_X_t`, an instance will be destroyed by any function which takes a mutable pointer to said instance, as this implies the instance's inners were moved.
/// To make this fact more obvious when reading your code, consider using `z_move(val)` instead of `&val` as the argument.
/// After a move, `val` will still exist, but will no longer be valid. The destructors are double-drop-safe, but other functions will still trust that your `val` is valid.
/// Like all `ze_owned_X_t`, an instance will be destroyed by any function which takes a mutable pointer to said instance, as this implies the instance's inners were moved.
/// To make this fact more obvious when reading your code, consider using `z_move(val)` instead of `&val` as the argument.
/// After a move, `val` will still exist, but will no longer be valid. The destructors are double-drop-safe, but other functions will still trust that your `val` is valid.
///
/// To check if `val` is still valid, you may use `z_X_check(&val)` or `z_check(val)` if your compiler supports `_Generic`, which will return `true` if `val` is valid.
#[repr(C)]
Expand Down Expand Up @@ -132,8 +132,8 @@ pub extern "C" fn ze_querying_subscriber_options_default() -> ze_querying_subscr
/// To check if the subscription succeeded and if the querying subscriber is still valid,
/// you may use `ze_querying_subscriber_check(&val)` or `z_check(val)` if your compiler supports `_Generic`, which will return `true` if `val` is valid.
///
/// Like all `ze_owned_X_t`, an instance will be destroyed by any function which takes a mutable pointer to said instance, as this implies the instance's inners were moved.
/// To make this fact more obvious when reading your code, consider using `z_move(val)` instead of `&val` as the argument.
/// Like all `ze_owned_X_t`, an instance will be destroyed by any function which takes a mutable pointer to said instance, as this implies the instance's inners were moved.
/// To make this fact more obvious when reading your code, consider using `z_move(val)` instead of `&val` as the argument.
/// After a move, `val` will still exist, but will no longer be valid. The destructors are double-drop-safe, but other functions will still trust that your `val` is valid.
///
/// Example:
Expand Down Expand Up @@ -234,6 +234,7 @@ pub unsafe extern "C" fn ze_querying_subscriber_get(
.target(options.target.into())
.consolidation(options.consolidation)
.timeout(std::time::Duration::from_millis(options.timeout_ms))
.accept_replies(options.accept_replies.into())
.callback(cb)
.res_sync(),
None => s.get(selector).callback(cb).res_sync(),
Expand Down