The Wayback Machine - https://web.archive.org/web/20220106085719/https://github.com/Rust-for-Linux/linux/issues/606
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

Create proper type for File's flags #606

Open
ojeda opened this issue Jan 4, 2022 · 2 comments
Open

Create proper type for File's flags #606

ojeda opened this issue Jan 4, 2022 · 2 comments

Comments

@ojeda
Copy link
Member

@ojeda ojeda commented Jan 4, 2022

From @wedsonaf #603 (comment):

One aspect of this PR that I'm not completely happy with is that we're returning a u32 without any mention of the meaning. So users need to read to the Rust code to figure out that it refers to f_flags, then the C code to figure out what those refer to, then they'll be forced to use constants in bindings to check specific flags.

So in addition to the winding path to find the actual flags, there is the problem that they are in a module that we intend to eventually make private.

For cases like this I've taken two different approaches, depending on whether the values can be ORed (which is the case here):

  1. If the values are unique, I declare an enum (e.g., ExtraResult)
  2. If they can be ORed, I declare a type and publish the constants in it (e.g., Type), then mention it in the documentation of the method (e.g., set_type).

Ideally we'd do something similar here.

@ojeda ojeda changed the title rust: File: Create proper type for flags Create proper type for File's flags Jan 4, 2022
@danobi
Copy link

@danobi danobi commented Jan 5, 2022

I can take this. I'll see if I can find any time this week/weekend

@felixfaisal
Copy link

@felixfaisal felixfaisal commented Jan 6, 2022

Can i take this on, Or probably shadow @danobi ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment