Re: [PATCH 2/4] rust: io_uring: introduce rust abstraction for io-uring cmd
From: Benno Lossin
Date: Tue Jul 22 2025 - 14:52:22 EST
On Tue Jul 22, 2025 at 4:30 PM CEST, Sidong Yang wrote:
> On Mon, Jul 21, 2025 at 06:28:09PM +0200, Benno Lossin wrote:
>> On Mon Jul 21, 2025 at 5:47 PM CEST, Sidong Yang wrote:
>> > It's safest to get NonNull from from_raw and it returns
>> > Pin<&mut IoUringCmd>.
>>
>> I don't think you need `NonNull<T>`.
>
> NonNull<T> gurantees that it's not null. It could be also dangling but it's
> safer than *mut T. Could you tell me why I don't need it?
Raw pointers have better ergonomics and if you're just passing it back
into ffi, I don't see the point of using `NonNull`...
>> > from_raw() name is weird. it should be from_nonnnull()? Also, done()
>> > would get Pin<&mut Self>.
>>
>> That sounds reasonable.
>>
>> Are you certain that it's an exclusive reference?
>
> As far as I know, yes.
So the `IoUringCmd` is not refcounted and it is also not owned by the
`done` callee?
---
Cheers,
Benno