rust_bigint/
lib.rs

1//! Provides traits for common functionality across several Rust BigInt implementations
2//!
3//! ## Example interaction:
4//! ```
5//! // import BigInt from this library. use a feature flag to select the BigInt you need
6//! // also, pull one or more traits from this library into scope
7//! use rust_bigint::BigInt;
8//! use rust_bigint::traits::Converter;
9//! 
10//! let number = BigInt::from(42);
11//! // now use one of the methods exposed by the converter trait
12//! let hex_str = number.to_hex();
13//! ```
14//!
15//! See the traits for more examples.
16
17pub mod serialize;
18pub mod traits;
19
20#[cfg(feature = "rust_gmp")]
21mod big_gmp;
22/// Expose selected BigInt type (defaults to GMP)
23#[cfg(feature = "rust_gmp")]
24pub type BigInt = gmp::mpz::Mpz;
25/// Expose error type associated with selected BigInt type (defaults to GMP)
26#[cfg(feature = "rust_gmp")]
27pub type HexError = gmp::mpz::ParseMpzError;
28
29#[cfg(feature = "num_bigint")]
30extern crate num_bigint;
31#[cfg(feature = "num_bigint")]
32extern crate num_integer;
33#[cfg(feature = "num_bigint")]
34extern crate num_traits;
35#[cfg(feature = "num_bigint")]
36pub type BigInt = num_bigint::BigInt;
37#[cfg(feature = "num_bigint")]
38pub type HexError = num_bigint::ParseBigIntError;
39#[cfg(feature = "num_bigint")]
40mod big_num;
41#[cfg(feature = "num_bigint")]
42mod big_num_gcd;