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
- blocking - Enables
FactorDbBlockingClient
which is a blocking alternative toFactorDbClient
and does not require async runtime.
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§
- Factor
DbBlocking Client - Blocking API client for FactorDB API.
- Factor
DbClient - Asynchronous API client for factorDB API.
Enums§
- Factor
DbError - Error type in this crate.