-
Notifications
You must be signed in to change notification settings - Fork 68
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
Module tree hygiene #56
Module tree hygiene #56
Conversation
Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
The 'functions' module subtree contains additional impl blocks for the Session and Pkcs11 structs. The pub elements of those blocks are accessible through those types whether or not their containing module is pub, so these just create extra documentation clutter. Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
Make the `types` module `pub(crate)` and re-export its contents through a new module structure. The new structure is intended to better group related concepts to make documentation easier to navigate. As a side effect, it also hoists all definitions up a level, making the tree wider, with individual items easier to navigate to. While the backing types module remains substantively unchanged, this does break the paths through which items are accessed in client code (see test diffs for examples). Version bumped to 0.3.0 to reflect this. Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
This moves the mechanism module out of types and into the location indicated in commit 20b26a5. src/types/mechanism/* -> src/mechanism/* src/types/mod.rs::MechanismFlags -> src/mechanism/flags.rs Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
This moves the sesson module out of types and into the location indicated in commit 20b26a5. src/types/session.rs -> src/session/mod.rs src/types/mod.rs::SessionFlags -> src/session/flags.rs Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
This moves the object module out of types and into the location indicated in commit 20b26a5. src/types/object.rs -> src/object.rs Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
This moves the slot module out of types and into the location indicated in commit 20b26a5. src/types/slot_token.rs -> src/slot/mod.rs src/types/mod.rs::{SlotFlags,TokenFlags} -> src/slot/flags.rs Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
This creates the context module out of the init module initially defined in commit 20b26a5 as well as main ctx definition from lib.rs. src/lib.rs::Pkcs11 -> src/context/mod.rs src/lib.rs::get_pkcs11 -> src/context/mod.rs src/types/locking.rs -> src/context/locking.rs src/types/mod.rs::Info -> src/context/info.rs src/types/mod.rs::InitializeFlags -> src/context/flags.rs Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
This moves the Rv enum out of the types module to match the crate scope it was placed at in commit 20b26a5. This allows the remainder of the contents of types to be restored by removing the prior misc definition. src/types/mod.rs -> src/types.rs src/types/function.rs -> src/rv.rs Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
Move previously crate-scope Error, Result, Rv, and RvError into their own module Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
The get_pcks11() accessor macro assumes it has access to private members of the Pkcs11 struct. As a result, any use of it outside this crate will fail to compile. This commit removes `macro_export` attribute which exposes it to client code. Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
17bcefa
to
454310c
Compare
Any reason not to just delete the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look sensible to me! Also, I'm happy with the objects
module being removed.
The imports for that failing doctest should also be fixed, though
Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
The functions module contains impl blocks for both the Session and Pcks11 structs. This commit moves those blocks into the respective modules where those structs are defined. Files session_management.rs and slot_token_mangement.rs contained impl blocks for both, and were split in the process. Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
This commit is much easier to view with whitespace ignored. Each method of the Session and Pcks11 structs implemented in a submodule is now exposed as a stub function. This has several advantages: * Functions remain internally categorized as in the PKCS#11 specification, while exposing a smooth interface. Previously each impl block, despite belonging to a single struct, would be shown in the public-facing docs, which created a lot of visual clutter. * The stubbed methods in the public modules can now collect arbitrarily large documentation blocks, without making the code itself difficult to navigate by being in one monolithic file Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
Signed-off-by: Keith Koskie <vkkoskie@gmail.com>
New commits. More file moves, which make diffs look much more drastic than they really are. Here's the summary: To try and respect the prior organization as much as possible, the methods previously located in the This provides what I think is a nice balance between the needs of developers and users of the crate. Users see a uniform struct uncluttered by impl annotations. This makes the struct itself monolithic which would be cumbersome to developers, but instead they get to work in the broken out files nearby. I wasn't sure if performance was of any concern, but I went ahead and removed the layer of indirection introduced by stubbing by forcing explicit inlining. Even if performance isn't a big concern, it does no harm. I also found what I think is a bug in |
@@ -88,7 +88,7 @@ impl Session<'_> { | |||
|
|||
/// Close a session | |||
/// This will be called on drop as well. | |||
pub fn close(&self) {} | |||
pub fn close(self) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good catch, otherwise close()
really didn't do anything.
I think I buy why you made those changes in |
Hmm. Github CI is unhappy with a part of the code I didn't touch. Maybe the rust image updated to a new version? Just a guess. |
Head branch was pushed to by a user without write access
Co-authored-by: Mike <michael.j.boquard@gmail.com> Signed-off-by: Michael J Boquard <michael.j.boquard@gmail.com>
Fix rustdoc tests Signed-off-by: Michael J Boquard <michael.j.boquard@gmail.com>
e7dafef
to
7919c61
Compare
Went ahead and made the changes and force pushed an updated commit to contain the 'magic' 'Signed-off-by' line. |
This PR introduces breaking changes. It attempts to resolve Issue #55, which has a more complete description of its rationale.
The changes are almost entirely structural. No function bodies or prototypes have changed, and the overall API is identical. The break comes only in the paths through which external users of the crate access its items. (e.g.,
use cryptoki::types::session::Session
is nowuse cryptoki::session::Session
but the Session struct is unchanged). The overall effect is a wider, shallower tree, where each module contains conceptually linked types. This produces a much more intuitive "front door" for documentation.Because file move diffs are often difficult to read, the PR is broken up into a series of commits each with its own detailed commit message to make review easier.
As I was making these changes, I also noticed a general misuse of visibility markers, and I suspect that more of the crate is exposed as pub than is ideal. While I did make several necessary changes from private to pub(crate) in order for moved items to be usable with the new structure, I only made one visibility change unrelated to this PR's primary goal. This is the final commit to the branch and removes the macro_export directive to take the get_pcks11 macro out of the public API (where it wouldn't have compiled anyway).
closes #55