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

add missing subscriber methods #871

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
3 changes: 3 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ Functions
.. doxygenfunction:: z_undeclare_subscriber
.. doxygenfunction:: z_declare_background_subscriber
.. doxygenfunction:: z_subscriber_keyexpr
.. doxygenfunction:: z_subscriber_id

.. doxygenfunction:: z_subscriber_drop

Expand Down Expand Up @@ -993,6 +994,8 @@ Functions
.. doxygenfunction:: ze_declare_advanced_subscriber
.. doxygenfunction:: ze_declare_background_advanced_subscriber
.. doxygenfunction:: ze_undeclare_advanced_subscriber
.. doxygenfunction:: ze_advanced_subscriber_keyexpr
.. doxygenfunction:: ze_advanced_subscriber_id

.. doxygenfunction:: ze_advanced_subscriber_detect_publishers
.. doxygenfunction:: ze_advanced_subscriber_detect_publishers_background
Expand Down
28 changes: 26 additions & 2 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ typedef struct ze_advanced_publisher_put_options_t {
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief A struct that represent missed samples.
* @brief A struct that represents missed samples.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
typedef struct ze_miss_t {
Expand Down Expand Up @@ -4750,6 +4750,14 @@ ZENOHC_API const struct z_loaned_string_t *z_string_loan(const struct z_owned_st
* This is equivalent to calling `z_undeclare_subscriber()` and discarding its return value.
*/
ZENOHC_API void z_subscriber_drop(struct z_moved_subscriber_t *this_);
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Returns the ID of the subscriber.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
struct z_entity_global_id_t z_subscriber_id(const struct z_loaned_subscriber_t *subscriber);
#endif
/**
* Returns the key expression of the subscriber.
*/
Expand Down Expand Up @@ -5655,7 +5663,7 @@ z_result_t ze_advanced_subscriber_declare_sample_miss_listener(const struct ze_l
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Declares a subscriber on liveliness tokens for matching publishers detection. Only advanced publishers. enabling publisher detection can be detected.
* @brief Declares a liveliness token listener for matching publishers detection. Only advanced publishers, enabling publisher detection can be detected.
*
* @param subscriber: The advanced subscriber instance.
* @param liveliness_subscriber: An uninitialized memory location where liveliness subscriber will be constructed.
Expand Down Expand Up @@ -5703,6 +5711,22 @@ void ze_advanced_subscriber_drop(struct ze_moved_advanced_subscriber_t *this_);
ZENOHC_API
void ze_advanced_subscriber_history_options_default(struct ze_advanced_subscriber_history_options_t *this_);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Returns the ID of the advanced subscriber.
*/
#if (defined(Z_FEATURE_UNSTABLE_API) && defined(Z_FEATURE_UNSTABLE_API))
ZENOHC_API
struct z_entity_global_id_t ze_advanced_subscriber_id(const struct ze_loaned_advanced_subscriber_t *subscriber);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* Returns the key expression of the advanced subscriber.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
const struct z_loaned_keyexpr_t *ze_advanced_subscriber_keyexpr(const struct ze_loaned_advanced_subscriber_t *subscriber);
#endif
/**
* Borrows subscriber.
*/
Expand Down
26 changes: 24 additions & 2 deletions src/advanced_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ pub extern "C" fn ze_undeclare_advanced_subscriber(
}

/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief A struct that represent missed samples.
/// @brief A struct that represents missed samples.
#[repr(C)]
pub struct ze_miss_t {
/// The source of missed samples.
Expand Down Expand Up @@ -465,7 +465,7 @@ fn _advanced_subscriber_detect_publishers_inner(
}

/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief Declares a subscriber on liveliness tokens for matching publishers detection. Only advanced publishers. enabling publisher detection can be detected.
/// @brief Declares a liveliness token listener for matching publishers detection. Only advanced publishers, enabling publisher detection can be detected.
///
/// @param subscriber: The advanced subscriber instance.
/// @param liveliness_subscriber: An uninitialized memory location where liveliness subscriber will be constructed.
Expand Down Expand Up @@ -518,3 +518,25 @@ pub extern "C" fn ze_advanced_subscriber_detect_publishers_background(
}
}
}

/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// Returns the key expression of the advanced subscriber.
#[no_mangle]
pub extern "C" fn ze_advanced_subscriber_keyexpr(
subscriber: &ze_loaned_advanced_subscriber_t,
) -> &z_loaned_keyexpr_t {
subscriber
.as_rust_type_ref()
.key_expr()
.as_loaned_c_type_ref()
}

#[cfg(feature = "unstable")]
/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief Returns the ID of the advanced subscriber.
#[no_mangle]
pub extern "C" fn ze_advanced_subscriber_id(
subscriber: &ze_loaned_advanced_subscriber_t,
) -> z_entity_global_id_t {
subscriber.as_rust_type_ref().id().into_c_type()
}
10 changes: 9 additions & 1 deletion src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::{
z_closure_sample_call, z_closure_sample_loan, z_loaned_session_t, z_moved_closure_sample_t,
};
#[cfg(feature = "unstable")]
use crate::{zc_locality_default, zc_locality_t};
use crate::{transmute::IntoCType, z_entity_global_id_t, zc_locality_default, zc_locality_t};

decl_c_type!(
owned(z_owned_subscriber_t, option Subscriber<()>),
Expand Down Expand Up @@ -205,3 +205,11 @@ pub extern "C" fn z_undeclare_subscriber(this_: &mut z_moved_subscriber_t) -> re
}
result::Z_OK
}

#[cfg(feature = "unstable")]
/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief Returns the ID of the subscriber.
#[no_mangle]
pub extern "C" fn z_subscriber_id(subscriber: &z_loaned_subscriber_t) -> z_entity_global_id_t {
subscriber.as_rust_type_ref().id().into_c_type()
}
Loading