Skip to content

Commit

Permalink
Cleanly error out when building without the alloc feature
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Jun 11, 2020
1 parent 8101840 commit ec31591
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,7 +11,7 @@ script:
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo test --verbose --all-features; fi
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo bench --verbose --all-features --no-run; fi
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then rustup target add thumbv7m-none-eabi; fi
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo build --verbose --no-default-features --target thumbv7m-none-eabi; fi
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo build --verbose --no-default-features --features=alloc --target thumbv7m-none-eabi; fi
- if [[ "$TRAVIS_NIGHTLY" != "true" ]]; then cargo test --verbose; fi

cache: cargo
18 changes: 18 additions & 0 deletions src/lib.rs
Expand Up @@ -49,6 +49,9 @@
//! ```
#![cfg_attr(not(test), no_std)]

#[cfg(not(feature = "alloc"))]
compile_error!("This crate does not yet support environments without liballoc. See https://github.com/RustCrypto/RSA/issues/51.");

#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
Expand All @@ -67,40 +70,55 @@ extern crate hex;
#[cfg(all(test, feature = "serde"))]
extern crate serde_test;

#[cfg(feature = "alloc")]
pub use num_bigint::BigUint;

/// Useful algorithms.
#[cfg(feature = "alloc")]
pub mod algorithms;

/// Error types.
#[cfg(feature = "alloc")]
pub mod errors;

/// Supported hash functions.
#[cfg(feature = "alloc")]
pub mod hash;

/// Supported padding schemes.
#[cfg(feature = "alloc")]
pub mod padding;

#[cfg(feature = "pem")]
pub use pem;

#[cfg(feature = "alloc")]
mod key;
#[cfg(feature = "alloc")]
mod oaep;
#[cfg(feature = "std")]
mod parse;
#[cfg(feature = "alloc")]
mod pkcs1v15;
#[cfg(feature = "alloc")]
mod pss;
#[cfg(feature = "alloc")]
mod raw;

#[cfg(feature = "alloc")]
pub use self::hash::Hash;
#[cfg(feature = "alloc")]
pub use self::key::{PublicKey, PublicKeyParts, RSAPrivateKey, RSAPublicKey};
#[cfg(feature = "alloc")]
pub use self::padding::PaddingScheme;

// Optionally expose internals if requested via feature-flag.

#[cfg(not(feature = "expose-internals"))]
#[cfg(feature = "alloc")]
mod internals;

/// Internal raw RSA functions.
#[cfg(feature = "expose-internals")]
#[cfg(feature = "alloc")]
pub mod internals;

0 comments on commit ec31591

Please sign in to comment.