Hi, I am wrapping a c library for a device and I am thinking how to model the opaque type on rust side. The device's documentation says:
On a single given connection, calling library functions is generally not thread-safe, i.e. they must be called from within one thread or the calls must be serialized/synchronized by the user.
For simplicity I started with
#[derive(Debug)]
pub struct DeviceHandle {
_marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}
which makes it not send and not sync. But I guess the doc says, that the type in fact is send but not sync. Is this interpretation correct? How can I achieve this? Is turning all &self
into &mut self
for all methods enough?
Thanks