ringbahn / iou

Rust interface to io_uring
Apache License 2.0
328 stars 22 forks source link

Clearly document lifetime requirements on SQE arguments #29

Open withoutboats opened 4 years ago

withoutboats commented 4 years ago

Any argument to an SQE prep method which is a reference (e.g. buffers, the mutable references in prep_accept) must outlive the completion of the IO event that is being prepared. There's no way to directly express this lifetime, as the completion of the IO is dynamic and unpredictable. This is the core reason these prep APIs are marked unsafe.

Users of iou are responsible for guaranteeing that these values will not be invalidated until after the completion occurs. We should provide clear, precise, and comprehensible documentation about the safety requirements of these methods.

Nugine commented 3 years ago

Would it be better to use a raw pointer (*mut [u8]) instead of a reference (&'unknown mut [u8])?