eclipse-zenoh / zenoh-c

C API for Zenoh
http://zenoh.io
Other
74 stars 54 forks source link

made closure param mutable #677

Closed milyin closed 2 weeks ago

milyin commented 2 weeks ago

Fix related to https://github.com/eclipse-zenoh/zenoh/issues/1372

Preparation for further making z_take operation for z_loaned_xxx_t* callback parameters. This will allow user to take ownership of data passed to callback without clone operation. This update is unsafe for C++, as in the zenoh-cpp it's already possible to perform std::move as soon as the callback parameter is not const. But in this update this is unsafe as on the rust side the non-owned objects are actually passed to callback. I.e. on rust side it's now &mut Sample represented as z_loaned_sample_t*. This means that it's prohibited at this moment to convert z_loaned_sample_t* to z_owned_sample_t* (which is Option<Sample> on rust side). But zenoh-cpp is built on assumption that it's safe to do this conversion because until this moment it was not possible to get z_loaned_xxx_t* reference directly to object other than z_owned_xxx_t.

The safety correction will be made in separate update to accelerate C++ API updating and to make verifying of safety update easier

github-actions[bot] commented 2 weeks ago

PR missing one of the required labels: {'enhancement', 'documentation', 'new feature', 'dependencies', 'internal', 'breaking-change', 'bug'}

github-actions[bot] commented 2 weeks ago

PR missing one of the required labels: {'documentation', 'dependencies', 'breaking-change', 'enhancement', 'internal', 'new feature', 'bug'}