eclipse-iceoryx / iceoryx2

Eclipse iceoryx2™ - true zero-copy inter-process-communication in pure Rust
https://iceoryx.io
Apache License 2.0
1.03k stars 40 forks source link

`SampleMut<MaybeUninit<T>>` offers `send` method #394

Closed elfenpiff closed 1 month ago

elfenpiff commented 1 month ago

Required Information

This is an API bug.

For the user it is possible to send an uninitialized sample, this must be prevented by the API otherwise it will induce undefined behavior in another application.

Example

// bad
let sample = publisher.loan_uninit()?;
sample.send()?; // must be a compile failure

// good
let mut sample = publisher.loan_uninit()?;
sample.write_payload(123);
let sample = unsafe { sample.assume_init() };
sample.send()?;