-
Notifications
You must be signed in to change notification settings - Fork 26
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
Revisit module structure and re-exports #155
Comments
Looks good. For the re-export of third-party crates I would go to the extent that they should generally be avoided. I don't really see the benefit of re-exporting the |
I think re-exports do have some benefits. Especially for types like |
We already have to do that for littlefs2 and many other crates because we're using git dependencies. You're right that for heapless-bytes and other dependencies where we don't use patch releases that much it's a benefit. |
I still hope for a future where we don’t need the Git dependencies … or at least only in the runner, not in every crate using Trussed. Actually, it would make sense to move |
This patch removes all re-exports of external types as discussed in trussed-dev#155, except for those that are essential for using Trussed: heapless_bytes::Bytes (only from the types module) and littlefs2::path::{Path, PathBuf}. Also, the cbor_smol re-exports in the main module are kept until we have a better mechanism for that. trussed-dev#155
As discussed in trussed-dev#155, this patch removes re-exports from types that are defined inside the crate. This means that all types that are defined in this crate are now only visible under one path. trussed-dev#155
This patch makes some modules of the core crate private and re-exports their contents from the crate root. This has two benefits: It makes it easier to read the crate documentation because the most important types are directly visible from the root. And it makes the imports for the most important types less verbose. See also: #155
This patch makes some modules of the core crate private and re-exports their contents from the crate root. This has two benefits: It makes it easier to read the crate documentation because the most important types are directly visible from the root. And it makes the imports for the most important types less verbose. See also: #155
This patch makes some modules of the core crate private and re-exports their contents from the crate root. This has two benefits: It makes it easier to read the crate documentation because the most important types are directly visible from the root. And it makes the imports for the most important types less verbose. See also: #155
When working on splitting Trussed into a client API and a backend implementation, I noticed the following:
Currently, many types that are declared in Trussed are re-exported in multiple locations. For example, the
Platform
trait:platform::Platform
Platform
(top-level)types::Platform
External types are also re-exported in multiple locations:
platform
re-exportsrand_core::{CryptoRng, RngCore}
types
re-exports, among others, many heapless and littlefs2 typesAt the same time, we have many modules that only contain one or two public types. For example,
error
only containsError
andResult
.store::certstore
only containsCertstore
andClientCertstore
. While it makes sense to group the implementation into a module, it does not make sense to usetrussed::error::Error
,trussed::store::certstore::Certstore
ortrussed::platform::Platform
to refer to these types.I propose the following guidelines for cleaning up imports and modules:
The goal of these changes would be to improve readability of the Trussed code and of the code using Trussed, to make it easier to import the correct types and to avoid surprising or unexpected imports.
I’m not sure how to deal with re-exports of external types. One option would be to only re-export them in a single location,
types
, or to have a re-export of the entire crate on the top-level and not re-export individual types.What do you think?
The text was updated successfully, but these errors were encountered: