Skip to content

Commit

Permalink
Clean up the openssl "vendored" feature mess
Browse files Browse the repository at this point in the history
The cleaner way is to take advantage of the single-dependency-deep
"slashed features" support in Cargo.toml to set features of direct
dependencies (not affecting recursive depnedencies) as implemented in
rust-lang/cargo#712
  • Loading branch information
mqudsi committed Dec 12, 2019
1 parent 25d7779 commit 9d39f47
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ license = "MIT"
edition = "2018"

[dependencies]
openssl = { version = "0.10", features = [ "vendored" ], optional = true }
openssl-sys = { package = "openssl", version = "0.10", optional = true }
openssl = { version = "0.10" }

[features]
default = [ "openssl" ]
system-openssl = [ "openssl-sys" ]
default = [ "openssl-vendored" ]
openssl-vendored = [ "openssl/vendored" ]

[dev-dependencies]
base64 = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion examples/read.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use base64::decode;
use cryptostream::read;
use cryptostream::Cipher;
use openssl::symm::Cipher;
use std::io::Read;

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions examples/readme.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use base64::decode;
use cryptostream::{read, write};
// openssl::Cipher is re-exported as cryptostream::Cipher
use cryptostream::Cipher;
use openssl::symm::Cipher;
use std::io::prelude::*;

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/write.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use base64::decode;
use cryptostream::write;
use cryptostream::Cipher;
use openssl::symm::Cipher;
use std::io::Write;

fn main() {
Expand Down
13 changes: 0 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,9 @@
//! [`bufread::Decryptor`] types for encrypting/decrypting plaintext/ciphertext on-the-fly from a
//! [`BufRead`](std::io::BufRead) source. (There is no need for a `bufwrite` variant.)
#[cfg(not(feature = "system-openssl"))]
extern crate openssl;
#[cfg(feature = "system-openssl")]
extern crate openssl_sys as openssl;

pub mod bufread;
pub mod read;
pub mod write;

/// Because we rename the openssl crate without the `vendored` feature as openssl_sys (you cannot
/// have a dependency imported (even XOR conditionally) twice with the same name, and you cannot
/// have conditional features for dependencies based off of your own feature in Cargo.toml), we
/// re-export the `openssl::symm:Cipher` as `cryptostream::Cipher` so no `extern crate openssl` is
/// required for downstream users of this library, which won't work if the `system-openssl` option
/// were used.
pub use openssl::symm::Cipher as Cipher;

#[cfg(test)]
mod tests;

0 comments on commit 9d39f47

Please sign in to comment.