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

Improve rustls cargo features #270

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Improve rustls cargo features #270

merged 1 commit into from
Sep 8, 2024

Conversation

soywod
Copy link
Contributor

@soywod soywod commented Sep 4, 2024

No description provided.

@duesee
Copy link
Owner

duesee commented Sep 4, 2024

Thanks! So the idea is to make aws-lc-rs vs ring configurable, right? Did you open this PR on purpose against @jakoschiko's feature branch? Or should it have been filed against main?

@jakoschiko
Copy link
Collaborator

I don't have much experience with feature flags. When does it make sense to forward feature flags like in this PR? I understand why it makes sense for crates that are tightly coupled and do re-exporting, e.g. imap-types and imap-codec. But why in this case?

If I understand feature flags correctly, you can simply add this to your Cargo.toml:

imap-next = "0.2.0"
tokio-rustls = { version = "*", features = ["ring"] }

And then the feature ring is activated for tokio-rustls because feature flags are additive. This is faster and more flexible than doing PRs in upstream crates. Am I missing something?

Using the re-exported rustls is good idea, though.

@soywod
Copy link
Contributor Author

soywod commented Sep 5, 2024

Did you open this PR on purpose against @jakoschiko's feature branch?

Yes, so it's based on the latest version of imap-{codec,types}.

And then the feature ring is activated for tokio-rustls because feature flags are additive. This is faster and more flexible than doing PRs in upstream crates. Am I missing something?

Because they are additive, we end up with both ring and aws-lc-rs. I think it is a common practice, look at tokio-rustls. The use case is the following: I'm a final user, and I already use rustls + ring in my code base. I don't want to build imap-next with rustls + aws-lc-rs. I understood it this way, I may be wrong as well. For sure I had the need, because I tried to fix Nix derivation that was complaining about aws-lc-rs even though I was not using in the codebase. Till this PR.

@jakoschiko
Copy link
Collaborator

Ah, now I understand, so aws-lc-rs is a default feature of tokio-rustls that's a problem for you. I think imap-next doesn't depend on any features of tokio-rustls, so disabling the default features should be okay.

My problem with this PR is that we arbitrarily forward some features of tokio-rustls and some not. Would you be happy with this?

[features]
default = [
    "stream",
    # These are the default features of tokio-rustls
    "tokio-rustls/logging",
    "tokio-rustls/tls12",
    "tokio-rustls/aws_lc_rs",
]
# ...

[dependencies]
tokio-rustls = { version = "0.26.0", optional = true, default-features = false }
# ...

Then you can use it like this:

imap-next = { version = "0.2.0", default-features = false, features = ["stream"] }
tokio-rustls = { version = "*", default-features = false, features = ["logging", "tls12", "ring"] }

@jakoschiko
Copy link
Collaborator

jakoschiko commented Sep 6, 2024

Or maybe just remove the default features?

[features]
default = ["stream"]
# ...

[dependencies]
tokio-rustls = { version = "0.26.0", optional = true, default-features = false }
# ...

Then you can use it like this:

imap-next = "0.2.0"
tokio-rustls = { version = "*", default-features = false, features = ["logging", "tls12", "ring"] }

I can't name any reason why imap-next should activate features of tokio-rustls.

@soywod
Copy link
Contributor Author

soywod commented Sep 8, 2024

Or maybe just remove the default features?

I think this should work, let me try.

@soywod soywod changed the base branch from jakoschiko_poison-message-with-fragmentizer to main September 8, 2024 08:08
@soywod
Copy link
Contributor Author

soywod commented Sep 8, 2024

Looks like it works as expected, ready to merge!

@soywod soywod changed the title Partially expose rustls features Improve rustls cargo features Sep 8, 2024
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 10758338673

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.1%) to 83.022%

Files with Coverage Reduction New Missed Lines %
src/receive.rs 2 80.72%
Totals Coverage Status
Change from base Build 10681591092: -0.1%
Covered Lines: 1022
Relevant Lines: 1231

💛 - Coveralls

@duesee duesee merged commit cc3e161 into duesee:main Sep 8, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants