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

ioctl! macro does not allow definition of public ioctl wrappers #184

Closed
codyps opened this issue Sep 1, 2015 · 3 comments
Closed

ioctl! macro does not allow definition of public ioctl wrappers #184

codyps opened this issue Sep 1, 2015 · 3 comments

Comments

@codyps
Copy link

codyps commented Sep 1, 2015

There doesn't seem to be an easy way to simply make public the generated ioctl wrappers without essentially duplicating all of their work (writing wrapping functions with the appropriate signature)

An easy way to prefix with 'pub' would be nice.

@posborne
Copy link
Member

posborne commented Sep 1, 2015

Ah, sure enough. I was hoping that it would be possible to just put pub in front, but this is clearly not the case.

posborne added a commit to posborne/nix-rust that referenced this issue Sep 1, 2015
Consumers of the API may control visibility by means of a module.  The
following is a useful pattern that may be used by implementors (here for
a couple of i2cdev ioctl definitions):

    mod ioctl {
        ioctl!(bad set_i2c_slave_address with super::I2C_SLAVE);
        ioctl!(bad i2c_smbus with super::I2C_SMBUS);
    }

This resolves nix-rust#184.
@posborne
Copy link
Member

posborne commented Sep 1, 2015

@jmesmon Any thoughts on having pub be what the ioctl supplies. This is what I have implemented now in my PR (#185). I'm thinking a common pattern might be to close over ioctl! definitions with mod ioctl namespace which gives the flexibility to control the visibility.

Other feedback welcome. If there are warts with the new interface, its probably best to fix them now before too many people have updated their code.

@codyps
Copy link
Author

codyps commented Sep 2, 2015

Well, I looked a bit further at what the current ioctl! macro provides while updating a few of my crates, and I ended up needing some wrapping functions anyhow (bare ioctls rarely make sense).

So despite me opening this issue, I'm not sure I really need a way to make the wrappers pub (that was just the first thing I reached for when updating things).

posborne added a commit to posborne/nix-rust that referenced this issue Sep 5, 2015
Consumers of the API may control visibility by means of a module.  The
following is a useful pattern that may be used by implementors (here for
a couple of i2cdev ioctl definitions):

    mod ioctl {
        ioctl!(bad set_i2c_slave_address with super::I2C_SLAVE);
        ioctl!(bad i2c_smbus with super::I2C_SMBUS);
    }

This resolves nix-rust#184.
@posborne posborne mentioned this issue Sep 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants