From 8055f3096b52d38eea964ae4f185c4243e4b8d10 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 11 Sep 2024 13:27:46 +0200 Subject: [PATCH] default functions added --- include/zenoh_commons.h | 22 ++++++++++++++++++---- src/session.rs | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index bb593ef72..cbad43868 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -437,11 +437,11 @@ typedef struct z_moved_session_t { struct z_owned_session_t _this; } z_moved_session_t; /** - * Options passed to the `z_open()` function. + * Options passed to the `z_close()` function. */ -typedef struct z_open_options_t { +typedef struct z_close_options_t { uint8_t _dummy; -} z_open_options_t; +} z_close_options_t; /** * A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: * @@ -789,6 +789,12 @@ typedef struct z_moved_keyexpr_t { typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; +/** + * Options passed to the `z_open()` function. + */ +typedef struct z_open_options_t { + uint8_t _dummy; +} z_open_options_t; /** * Represents the set of options that can be applied to the delete operation by a previously declared publisher, * whenever issued via `z_publisher_delete()`. @@ -1850,7 +1856,11 @@ ZENOHC_API struct z_clock_t z_clock_now(void); */ ZENOHC_API z_result_t z_close(struct z_moved_session_t *session, - const struct z_open_options_t *_options); + const struct z_close_options_t *_options); +/** + * Constructs the default value for `z_close_options_t`. + */ +ZENOHC_API void z_close_options_default(struct z_close_options_t *this_); /** * Calls the closure. Calling an uninitialized closure is a no-op. */ @@ -3363,6 +3373,10 @@ ZENOHC_API z_result_t z_open(struct z_owned_session_t *this_, struct z_moved_config_t *config, const struct z_open_options_t *_options); +/** + * Constructs the default value for `z_open_options_t`. + */ +ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); /** * @attention Unstable feature. * @brief Constructs and opens a new Zenoh session with specified client storage. diff --git a/src/session.rs b/src/session.rs index 908c308d9..26eb5e296 100644 --- a/src/session.rs +++ b/src/session.rs @@ -53,6 +53,14 @@ pub struct z_open_options_t { _dummy: u8, } +/// Constructs the default value for `z_open_options_t`. +#[no_mangle] +pub extern "C" fn z_open_options_default(this_: &mut MaybeUninit) { + this_.write(z_open_options_t { + _dummy: 0, + }); +} + /// Constructs and opens a new Zenoh session. /// /// @return 0 in case of success, negative error code otherwise (in this case the session will be in its gravestone state). @@ -135,6 +143,14 @@ pub struct z_close_options_t { _dummy: u8, } +/// Constructs the default value for `z_close_options_t`. +#[no_mangle] +pub extern "C" fn z_close_options_default(this_: &mut MaybeUninit) { + this_.write(z_close_options_t { + _dummy: 0, + }); +} + /// Closes a zenoh session. This alos drops and invalidates `session`. /// /// @return 0 in case of success, a negative value if an error occured while closing the session, @@ -142,7 +158,7 @@ pub struct z_close_options_t { #[no_mangle] pub extern "C" fn z_close( session: &mut z_moved_session_t, - _options: Option<&z_open_options_t>, + _options: Option<&z_close_options_t>, ) -> result::z_result_t { let Some(s) = session.take_rust_type() else { return result::Z_EINVAL;