Crate factordb

Source
Expand description

Rust wrapper for FactorDB API.

§Examples

Basic usage:

use std::error::Error;
use factordb::FactorDbClient;
use num_bigint::BigInt; // All numeric values in the result object are of this type

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    // Initialise the client
    let client = FactorDbClient::new();

    // Make requests
    let forty_two = client.get(42).await?;
    let expect_factors: Vec<BigInt> = vec![2, 3, 7].into_iter().map(|n| BigInt::from(n)).collect();
    assert_eq!(forty_two.into_factors_flattened(), expect_factors);

    Ok(())
 }

§Crate features

Re-exports§

pub use factor::Factor;
pub use number::Number;
pub use number::NumberStatus;

Modules§

factor
Contains struct containing a factor and its iterators.
number
Contains response struct for FactorDB API requests, excluding the factors (see crate::factor for that).

Structs§

FactorDbBlockingClient
Blocking API client for FactorDB API.
FactorDbClient
Asynchronous API client for factorDB API.

Enums§

FactorDbError
Error type in this crate.