Skip to content

Commit

Permalink
remove unstable requirement from functionality that is stable in rust (
Browse files Browse the repository at this point in the history
…#772)

* remove unstable requirement from functionality that is stable in rust

* fix test
  • Loading branch information
DenisBiryukov91 authored Oct 16, 2024
1 parent a874982 commit 1765a25
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 46 deletions.
7 changes: 0 additions & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.c")

foreach(file ${files})
get_filename_component(target ${file} NAME_WE)

# Exclude some examples if UNSTABLE feature is disabled
if(NOT(ZENOHC_BUILD_WITH_UNSTABLE_API))
if(${target} STREQUAL "z_info")
continue()
endif()
endif()
# Exclude SHM examples if SHM feature is disabled
if(NOT(ZENOHC_BUILD_WITH_SHARED_MEMORY AND (ZENOHC_BUILD_WITH_UNSTABLE_API)))
if(${target} MATCHES "^.*_shm.*$")
Expand Down
5 changes: 1 addition & 4 deletions examples/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "zenoh.h"

#if defined(Z_FEATURE_UNSTABLE_API)
void fprintpid(FILE *stream, z_id_t pid) {
int len = 0;
for (int i = 0; i < 16; i++) {
Expand All @@ -33,7 +32,6 @@ void fprintpid(FILE *stream, z_id_t pid) {
fprintf(stream, ")");
}
}
#endif

void fprintwhatami(FILE *stream, z_whatami_t whatami) {
z_view_string_t whatami_str;
Expand All @@ -57,9 +55,8 @@ void fprintlocators(FILE *stream, const z_loaned_string_array_t *locs) {

void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, "Hello { pid: ");
#if defined(Z_FEATURE_UNSTABLE_API)

fprintpid(stream, z_hello_zid(hello));
#endif
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));

Expand Down
23 changes: 4 additions & 19 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,6 @@ typedef struct z_owned_closure_sample_t {
typedef struct z_moved_closure_sample_t {
struct z_owned_closure_sample_t _this;
} z_moved_closure_sample_t;
/**
* @brief A Zenoh ID.
*
* In general, valid Zenoh IDs are LSB-first 128bit unsigned and non-zero integers.
*/
typedef struct ALIGN(1) z_id_t {
uint8_t id[16];
} z_id_t;
/**
* @brief A zenoh id-processing closure.
*
Expand Down Expand Up @@ -2527,13 +2519,9 @@ void z_hello_locators(const struct z_loaned_hello_t *this_,
*/
ZENOHC_API enum z_whatami_t z_hello_whatami(const struct z_loaned_hello_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 id of Zenoh entity that transmitted hello message.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
struct z_id_t z_hello_zid(const struct z_loaned_hello_t *this_);
#endif
ZENOHC_API struct z_id_t z_hello_zid(const struct z_loaned_hello_t *this_);
/**
* @brief Formats the `z_id_t` into 16-digit hex string (LSB-first order)
*/
Expand Down Expand Up @@ -2651,7 +2639,8 @@ ZENOHC_API bool z_internal_closure_zid_check(const struct z_owned_closure_zid_t
/**
* @brief Constructs a null closure.
*/
ZENOHC_API void z_internal_closure_zid_null(struct z_owned_closure_zid_t *this_);
ZENOHC_API
void z_internal_closure_zid_null(struct z_owned_closure_zid_t *this_);
/**
* Returns ``true`` if conditional variable is valid, ``false`` otherwise.
*/
Expand Down Expand Up @@ -4382,13 +4371,9 @@ ZENOHC_API
const char *z_time_now_as_str(const char *buf,
size_t len);
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
* @brief Returns id associated with this timestamp.
*/
#if defined(Z_FEATURE_UNSTABLE_API)
ZENOHC_API
struct z_id_t z_timestamp_id(const struct z_timestamp_t *this_);
#endif
ZENOHC_API struct z_id_t z_timestamp_id(const struct z_timestamp_t *this_);
/**
* Create uhlc timestamp from session id.
*/
Expand Down
2 changes: 1 addition & 1 deletion splitguide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ zenoh_opaque.h:
- z_owned_source_info_t!#unstable
- z_loaned_source_info_t!#unstable
- z_entity_global_id_t!#unstable
- z_id_t!#unstable
- z_id_t!
- z_timestamp_t!
- z_owned_publisher_t!
- z_loaned_publisher_t!
Expand Down
6 changes: 1 addition & 5 deletions src/commons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ use zenoh::{
#[cfg(feature = "unstable")]
use crate::transmute::IntoCType;
#[cfg(feature = "unstable")]
use crate::z_id_t;
#[cfg(feature = "unstable")]
use crate::z_moved_source_info_t;
use crate::{
result,
transmute::{CTypeRef, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType},
z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t,
z_id_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t,
};

/// A zenoh unsigned integer
Expand Down Expand Up @@ -92,8 +90,6 @@ pub extern "C" fn z_timestamp_ntp64_time(this_: &z_timestamp_t) -> u64 {
this_.as_rust_type_ref().get_time().0
}

#[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 id associated with this timestamp.
#[no_mangle]
pub extern "C" fn z_timestamp_id(this_: &z_timestamp_t) -> z_id_t {
Expand Down
8 changes: 2 additions & 6 deletions src/scouting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ use zenoh::{
pub use crate::opaque_types::{z_loaned_hello_t, z_moved_hello_t, z_owned_hello_t};
use crate::{
result::{self, Z_OK},
transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType},
z_closure_hello_call, z_closure_hello_loan, z_moved_closure_hello_t, z_moved_config_t,
transmute::{IntoCType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType},
z_closure_hello_call, z_closure_hello_loan, z_id_t, z_moved_closure_hello_t, z_moved_config_t,
z_owned_string_array_t, z_view_string_t, CString, CStringView, ZVector,
};
#[cfg(feature = "unstable")]
use crate::{transmute::IntoCType, z_id_t};
decl_c_type!(
owned(z_owned_hello_t, option Hello ),
loaned(z_loaned_hello_t),
Expand Down Expand Up @@ -70,8 +68,6 @@ pub extern "C" fn z_hello_clone(dst: &mut MaybeUninit<z_owned_hello_t>, this_: &
.write(Some(this_.as_rust_type_ref().clone()));
}

#[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 id of Zenoh entity that transmitted hello message.
#[no_mangle]
pub extern "C" fn z_hello_zid(this_: &z_loaned_hello_t) -> z_id_t {
Expand Down
4 changes: 0 additions & 4 deletions tests/z_api_alignment_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@

const char *value = "Test value";

#if defined(Z_FEATURE_UNSTABLE_API)
volatile unsigned int zids = 0;
void zid_handler(const z_id_t *id, void *arg) {
(void)(arg);
(void)(id);
zids++;
}
#endif

volatile unsigned int hellos = 0;
void hello_handler(z_loaned_hello_t *hello, void *arg) {
Expand Down Expand Up @@ -201,7 +199,6 @@ int main(int argc, char **argv) {
assert(0 == z_open(&s1, z_move(_ret_config), NULL));
assert(z_internal_check(s1));

#if defined(Z_FEATURE_UNSTABLE_API)
z_id_t _ret_zid = z_info_zid(z_loan(s1));
z_owned_string_t str;
z_id_to_string(&_ret_zid, &str);
Expand All @@ -221,7 +218,6 @@ int main(int argc, char **argv) {

z_sleep_s(SLEEP);
assert(zids == 1);
#endif

#ifdef ZENOH_PICO
zp_task_read_options_t _ret_read_opt = zp_task_read_options_default();
Expand Down

0 comments on commit 1765a25

Please sign in to comment.