-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The zenoh-c API proposes two patterns for opaque mapping Rust structures to C:
z_owned_xxx_t- the "owned" type is created by constructing function and have to be dropped with destructor in the end of it's lifetime, as it may contain external references (allocated memory, handles, etc). Most of types are like this: e.g.z_owned_sample_tfor rust'sSamplez_xxx_tfor bitwise copyable types. The examples arez_id_tforZenohIdandz_timestamp_t
Recently the type z_source_info_t was made instead of z_owned_source_info_t. This change is potentially dangerous as on the rust side the corresponding SourceInfo type doesn't implement Copy trait and therefore in some future update can be modified to hold non-copy field (e.g. store some long string on the heap). This will make C API incompatible with rust one.
Solution:
- add "#[derive(Copy)]" to
SourceInfoon the rust side to explicily guarantee thatSourceInfowill be always bitwise copyable - add to the macro
decl_c_type!(copy ...validation, that the corresponding rust type implementsCopytrait to avoid such deviations in future
To reproduce
=
System info
=
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working