tokio-rs / tokio-uring

An io_uring backed runtime for Rust
MIT License
1.14k stars 122 forks source link

api change: have statx return a boxed value #225

Open FrankReh opened 1 year ago

FrankReh commented 1 year ago

The statx command, as is currently implemented requires we create a boxed value while we wait for the future to complete. As the last step, we copy the value from the box to the caller's stack frame, dropping the box.

How about we return the box itself. The caller then owns the box and can drop it or save it, as they wish.

And while I'm at changing the API, why not wrap the value in our own new Statx struct that has some well known methods built into it so the caller doesn't have to dig into the libc:statx structure all the time.

So I'm proposing the File::statx call return a Box.

Also, there will be a general statx function that takes a path reference and a StatxBuilder that allows other flags and mask values to be set - so a file doesn't have to be opened first and later closed. They would all return a Box. The builder could even allow a Box to be passed to it to reuse a box.

Noah-Kennedy commented 1 year ago

I'm not necessarily opposed to this idea.