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 24a4b1b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
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 24a4b1b

Please sign in to comment.