wyyerd / stripe-rs

Rust API bindings for the Stripe HTTP API.
Apache License 2.0
224 stars 88 forks source link

Implement feature flags to help reduce binary size #99

Closed kestred closed 4 years ago

kestred commented 4 years ago

Attempting to improve the situation described in #96.

This change allows parts of the library to be included/excluded via feature flags, to help reduce code bloat for the common use cases where many modules of the stripe api are unused (like the Connect or Sigma APIs).

# Example: Full Stripe API
stripe-rust = "*"       // ---> defaults to `{ features = ["full", "webhook-events"] }`

# Example: Core-only (enough to create a `Charge` or `Card` or `Customer`)
stripe-rust = { version = "*", default-features = false }

# Example: Support for "Subscriptions" and "Invoices"
stripe-rust = { version = "*", default-features = false, features = ["billing"] }

If only the core api is enabled (which is sufficient to charge a customer), it reduces the .rlib size by 50-60%.