From 32643ed896ae1bade8da14a15df14c32f7d63c6a Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Wed, 16 Oct 2024 17:36:39 +0200 Subject: [PATCH] make z_id_closure stable --- include/zenoh_commons.h | 36 +++------------------------------ src/closures/mod.rs | 2 -- src/closures/zenohid_closure.rs | 7 ------- src/info.rs | 4 ---- src/scouting.rs | 6 ++---- 5 files changed, 5 insertions(+), 50 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 7ed43d240..dd0bd69be 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -346,27 +346,21 @@ typedef struct z_moved_closure_sample_t { struct z_owned_closure_sample_t _this; } z_moved_closure_sample_t; /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief A zenoh id-processing closure. * * A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: */ -#if defined(Z_FEATURE_UNSTABLE_API) typedef struct z_owned_closure_zid_t { void *_context; void (*_call)(const struct z_id_t *z_id, void *context); void (*_drop)(void *context); } z_owned_closure_zid_t; -#endif /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Moved closure. */ -#if defined(Z_FEATURE_UNSTABLE_API) typedef struct z_moved_closure_zid_t { struct z_owned_closure_zid_t _this; } z_moved_closure_zid_t; -#endif typedef struct z_moved_condvar_t { struct z_owned_condvar_t _this; } z_moved_condvar_t; @@ -1568,38 +1562,27 @@ const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_own * @param drop: an optional function to be called once on closure drop. * @param context: closure context. */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid(struct z_owned_closure_zid_t *this_, void (*call)(const struct z_id_t *z_id, void *context), void (*drop)(void *context), void *context); -#endif /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Calls the closure. Calling an uninitialized closure is a no-op. */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure, const struct z_id_t *z_id); -#endif /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized (null) closure is a no-op. */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid_drop(struct z_moved_closure_zid_t *closure_); -#endif /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Borrows closure. */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API const struct z_loaned_closure_zid_t *z_closure_zid_loan(const struct z_owned_closure_zid_t *closure); -#endif /** * Drops conditional variable. */ @@ -2327,16 +2310,12 @@ ZENOHC_API enum z_whatami_t z_hello_whatami(const struct z_loaned_hello_t *this_ */ ZENOHC_API struct z_id_t z_hello_zid(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 Formats the `z_id_t` into 16-digit hex string (LSB-first order) */ #if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void z_id_to_string(const struct z_id_t *zid, - struct z_owned_string_t *dst); +ZENOHC_API void z_id_to_string(const struct z_id_t *zid, struct z_owned_string_t *dst); #endif /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Fetches the Zenoh IDs of all connected peers. * * `callback` will be called once for each ID, is guaranteed to never be called concurrently, @@ -2350,7 +2329,6 @@ z_result_t z_info_peers_zid(const struct z_loaned_session_t *session, struct z_moved_closure_zid_t *callback); #endif /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Fetches the Zenoh IDs of all connected routers. * * `callback` will be called once for each ID, is guaranteed to never be called concurrently, @@ -2364,7 +2342,6 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, struct z_moved_closure_zid_t *callback); #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 session's Zenoh ID. * * Unless the `session` is invalid, that ID is guaranteed to be non-zero. @@ -2372,8 +2349,7 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, * to pass it a valid session. */ #if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct z_id_t z_info_zid(const struct z_loaned_session_t *session); +ZENOHC_API struct z_id_t z_info_zid(const struct z_loaned_session_t *session); #endif /** * Returns ``true`` if `this` is valid. @@ -2452,21 +2428,15 @@ ZENOHC_API bool z_internal_closure_sample_check(const struct z_owned_closure_sam */ ZENOHC_API void z_internal_closure_sample_null(struct z_owned_closure_sample_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 ``true`` if closure is valid, ``false`` if it is in gravestone state. */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool z_internal_closure_zid_check(const struct z_owned_closure_zid_t *this_); -#endif +ZENOHC_API bool z_internal_closure_zid_check(const struct z_owned_closure_zid_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs a null closure. */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_internal_closure_zid_null(struct z_owned_closure_zid_t *this_); -#endif /** * Returns ``true`` if conditional variable is valid, ``false`` otherwise. */ diff --git a/src/closures/mod.rs b/src/closures/mod.rs index 56fcaad4d..29b33867b 100644 --- a/src/closures/mod.rs +++ b/src/closures/mod.rs @@ -20,9 +20,7 @@ mod query_closure; pub use reply_closure::*; mod reply_closure; -#[cfg(feature = "unstable")] pub use zenohid_closure::*; -#[cfg(feature = "unstable")] mod zenohid_closure; pub use response_channel::*; diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs index cb491a803..a5104bed3 100644 --- a/src/closures/zenohid_closure.rs +++ b/src/closures/zenohid_closure.rs @@ -20,7 +20,6 @@ use crate::{ transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, z_id_t, }; -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief A zenoh id-processing closure. /// /// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: @@ -31,14 +30,12 @@ pub struct z_owned_closure_zid_t { _drop: Option, } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Loaned closure. #[repr(C)] pub struct z_loaned_closure_zid_t { _0: [usize; 3], } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Moved closure. #[repr(C)] pub struct z_moved_closure_zid_t { @@ -76,7 +73,6 @@ impl Drop for z_owned_closure_zid_t { } } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] @@ -94,7 +90,6 @@ pub unsafe extern "C" fn z_internal_closure_zid_null( this_.write(z_owned_closure_zid_t::default()); } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Calls the closure. Calling an uninitialized closure is a no-op. #[no_mangle] pub extern "C" fn z_closure_zid_call(closure: &z_loaned_closure_zid_t, z_id: &z_id_t) { @@ -107,7 +102,6 @@ pub extern "C" fn z_closure_zid_call(closure: &z_loaned_closure_zid_t, z_id: &z_ } } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized (null) closure is a no-op. #[no_mangle] pub extern "C" fn z_closure_zid_drop(closure_: &mut z_moved_closure_zid_t) { @@ -132,7 +126,6 @@ impl From for z_owned_closure_zid_t { } } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Borrows closure. #[no_mangle] pub extern "C" fn z_closure_zid_loan(closure: &z_owned_closure_zid_t) -> &z_loaned_closure_zid_t { diff --git a/src/info.rs b/src/info.rs index a2437c324..d056fc01b 100644 --- a/src/info.rs +++ b/src/info.rs @@ -30,7 +30,6 @@ impl From<[u8; 16]> for z_id_t { } } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Formats the `z_id_t` into 16-digit hex string (LSB-first order) #[no_mangle] pub extern "C" fn z_id_to_string(zid: &z_id_t, dst: &mut MaybeUninit) { @@ -38,7 +37,6 @@ pub extern "C" fn z_id_to_string(zid: &z_id_t, dst: &mut MaybeUninit z_id_t { session.info().zid().wait().into_c_type() } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Fetches the Zenoh IDs of all connected peers. /// /// `callback` will be called once for each ID, is guaranteed to never be called concurrently, @@ -72,7 +69,6 @@ pub unsafe extern "C" fn z_info_peers_zid( result::Z_OK } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Fetches the Zenoh IDs of all connected routers. /// /// `callback` will be called once for each ID, is guaranteed to never be called concurrently, diff --git a/src/scouting.rs b/src/scouting.rs index 069568a9e..14d1b4712 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -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),