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

refactor functions in the pkcs11/api folder #138

Open
nponsard opened this issue Sep 19, 2023 · 1 comment
Open

refactor functions in the pkcs11/api folder #138

nponsard opened this issue Sep 19, 2023 · 1 comment
Labels
Developer QoL Code changes to improve the readability and mainanibility of the project priority: low

Comments

@nponsard
Copy link
Contributor

nponsard commented Sep 19, 2023

The idea would be to move the logic out of these functions, only the mapping of the input and the output would be done here.

This would be only a developer quality of life change and is purely optional since everything is already implemented.

From #92:

Some complexity in the API functions comes from the custom error handling with CK_RV. It’s probably not worth to change it now that almost everything is implemented, but a helper macro that makes it possible to write Result<(), CK_RV> functions instead could be more ergonomic. Alternatively, the logic could be moved to safe functions returning Result<_, CK_RV> and the extern "C" functions only perform the mapping between the input and output.

@nponsard nponsard added the Developer QoL Code changes to improve the readability and mainanibility of the project label Sep 26, 2023
@sosthene-nitrokey
Copy link
Contributor

This would allow:

  • Functions that return Result<(), CK_RV> for example to replace the ensure_init macro in Fix panics on failed initialization #165
  • If the rust API explicitly takes a &Device and references to the other statics it would allow better management of the statics and make testing with custom values easier. The statics would only be accessed in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer QoL Code changes to improve the readability and mainanibility of the project priority: low
Projects
None yet
Development

No branches or pull requests

2 participants