rusqsieve 0.2.1

High-performance SIQS integer factorization for native Rust and WebAssembly
Documentation
#![doc = include_str!("../README.md")]
#![deny(missing_docs)]
#![cfg_attr(
    not(all(target_arch = "wasm32", target_os = "unknown")),
    deny(unsafe_code)
)]
#![deny(unsafe_op_in_unsafe_fn)]

// Internal kernels are intentionally compiled in different combinations by
// native, Wasm coordinator, Wasm worker, and reference-engine builds.
#[allow(dead_code)]
mod f2;
#[allow(dead_code)]
mod natural;
#[allow(dead_code)]
mod progress;
#[allow(dead_code)]
mod qs;

#[allow(dead_code)]
mod factor;
mod factors;
#[allow(dead_code)]
mod primality;
#[allow(dead_code)]
mod work;

#[allow(dead_code)]
mod engine;

#[cfg(any(unix, windows))]
mod native;

// Raw pointers are confined to the native C ABI boundary. The rest of the
// native crate remains under `deny(unsafe_code)`.
#[cfg(any(unix, windows))]
#[allow(unsafe_code)]
mod capi;

mod smallfactor;

#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
mod wasm;

pub use factor::{FactorConfig, FactorError, Parallelism, ProgressAction, ResourceLimitKind};
pub use factors::PrimeFactors;
pub use natural::{BufferTooSmall, CapacityError, Natural, ParseNaturalError};
pub use progress::{ProgressAmount, ProgressPhase, ProgressSnapshot, ProgressTotal, ProgressUnit};

pub(crate) use factor::{AdvanceOutcome, FactorSession, LocalWorkBudget};
pub(crate) use natural::{PARTS, jacobi_u64, legendre_u32, tonelli_shanks_u32};
pub(crate) use primality::{PrimalityConfig, is_probable_prime};

#[cfg(any(unix, windows))]
pub use native::{factor, factor_with, factor_with_progress};

/// Constructs a fixed-capacity integer from a decimal literal at compile time.
///
/// The second argument is the number of 64-bit limbs. Invalid decimal text or
/// a value wider than the requested capacity causes a compile-time error.
///
/// ```
/// use rusqsieve::{Natural, natural};
///
/// const N: Natural<2> = natural!("340282366920938463463374607431768211455", 2);
/// assert_eq!(N, Natural::<2>::MAX);
/// ```
#[macro_export]
macro_rules! natural {
    ($value:literal, $parts:literal) => {{
        const VALUE: $crate::Natural<$parts> = match $crate::Natural::<$parts>::from_decimal($value)
        {
            Ok(value) => value,
            Err(_) => panic!("invalid or overflowing Natural literal"),
        };
        VALUE
    }};
}