arlyon / async-stripe

Async (and blocking!) Rust bindings for the Stripe API
https://payments.rs
Apache License 2.0
418 stars 122 forks source link

fails to compile without runtime #463

Open dvc94ch opened 6 months ago

dvc94ch commented 6 months ago

Describe the bug

makes sense to reexport some of the types to a frontend, not clear why a runtime is required

To Reproduce

cargo build --no-default-features

Expected behavior

builds fine

Code snippets

No response

OS

any

Rust version

any

Library version

since build.rs was added 7mo ago

API version

not stripe related

Additional context

No response

arlyon commented 6 months ago

The library is not designed to just expose the types but I am open to a change that adapts it to do so, as there is nothing that inherently prevents it.

cortopy commented 1 month ago

An extra use case. I'm building a crate with small testing utilities. I want to generate fake payment ids so that my structs can easily use the Fake treat from fake crate like:

use std::str::FromStr;

use fake::{Fake, StringFaker};
use stripe::PaymentIntentId;

const ALPHANUMERIC: &str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

pub fn fake_payment_intent_id() -> PaymentIntentId {
    let payment_id_faker = StringFaker::with(Vec::from(ALPHANUMERIC), 24);
    let id: String = payment_id_faker.fake();
    PaymentIntentId::from_str(&format!("pi_{id}")).expect("PaymentIntentId faker should work")
}

The problem is that I have to include a runtime and what is supposed to be a tiny crate now it's blown out of proportion in terms of size and compilation time

arlyon commented 1 month ago

This issue will be fixed in the next release. please see the next branch for a pre-release version :) It is not really ready for use yet but it is coming