Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api change: have statx return a boxed value #225

Open
FrankReh opened this issue Feb 4, 2023 · 1 comment
Open

api change: have statx return a boxed value #225

FrankReh opened this issue Feb 4, 2023 · 1 comment
Labels

Comments

@FrankReh
Copy link
Collaborator

FrankReh commented Feb 4, 2023

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
Copy link
Contributor

I'm not necessarily opposed to this idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants