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

Placed SSL/TLS dependencies behind a default feature flag #124

Closed
wants to merge 1 commit into from

Conversation

lberezy
Copy link
Contributor

@lberezy lberezy commented May 6, 2019

#123
This allows usage of the crate without a dependency on SSL/TLS.

By default, the "ssl" feature is included in the dependencies as to not cause any breaking changes.

Note that I have not run any of the functional tests in the test suite.

@codecov
Copy link

codecov bot commented May 6, 2019

Codecov Report

Merging #124 into master will decrease coverage by 0.4%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #124      +/-   ##
==========================================
- Coverage    79.2%   78.79%   -0.41%     
==========================================
  Files          11       11              
  Lines        1159     1165       +6     
==========================================
  Hits          918      918              
- Misses        241      247       +6
Impacted Files Coverage Δ
src/client.rs 86.84% <ø> (ø) ⬆️
tests/imap_integration.rs 98.97% <ø> (ø) ⬆️
src/extensions/idle.rs 0% <ø> (ø) ⬆️
src/error.rs 3.12% <0%> (-0.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fec0fba...9015f3f. Read the comment docs.

@@ -22,8 +24,10 @@ pub enum Error {
/// An `io::Error` that occurred while trying to read or write to a network stream.
Io(IoError),
/// An error from the `native_tls` library during the TLS handshake.
#[cfg(feature = "ssl")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and some of the other changes) would make the ssl feature non-additive, which causes problems. I'm not entirely sure that there's a way to work around this :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is a tricky one to solve cleanly, especially without any breaking changes (split the enum into subset/superset relationship).
Perhaps it is appropriate though to allow this as the current API of the crate makes it a conscious decision to create a secure or insecure session - it would not be possible anyway to switch from not having the ssl feature to having it without also having to adapt other parts of a user's code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately crate authors do not have the option of choosing. Since cargo assumes that features are additive, it will automatically pick the maximal set of features for any dependency. For example if a and b both depended on imap, one with the feature and one without, cargo would only compile imap once with the feature and then compile both a and b against that, at which point b would fail to compile if it ever tried to match over the errors for example. That's far from ideal..

@@ -20,6 +21,7 @@ impl imap::Authenticator for GmailOAuth2 {
}
}

#[cfg(feature = "ssl")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better here to list the example in Cargo.toml with required-features = ["ssl"] (assuming that works).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about required-features. Seems like that's a much better solution, thanks.

@@ -1,18 +1,21 @@
extern crate imap;
extern crate lettre;
extern crate lettre_email;
#[cfg(feature = "ssl")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's probably fine for native-tls to always be included in dev-dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good pickup, that makes sense.

@lberezy
Copy link
Contributor Author

lberezy commented May 6, 2019

I'm also considering renaming the feature flag to "tls" as I think that's more appropriate in 2019.

@brycefisher brycefisher mentioned this pull request Sep 25, 2019
@jonhoo
Copy link
Owner

jonhoo commented Sep 25, 2019

Implemented in #140.

@jonhoo jonhoo closed this Sep 25, 2019
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.

2 participants