From 54d7a1b7adf6ec20a1af665b46bb0f2b356b6f06 Mon Sep 17 00:00:00 2001 From: Kevin Stenerson Date: Mon, 16 Dec 2019 03:07:21 -0700 Subject: [PATCH] Implement all feature flags --- .travis.yml | 5 +- Cargo.toml | 26 ++- bench/dependecy_weight.toml | 29 ++++ openapi/src/metadata.rs | 16 +- src/resources.rs | 295 ++++++++++++++++++---------------- src/resources/placeholders.rs | 29 +--- 6 files changed, 210 insertions(+), 190 deletions(-) create mode 100644 bench/dependecy_weight.toml diff --git a/.travis.yml b/.travis.yml index 3e40bab8..5b5e63cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ script: - rustup component add rustfmt - cargo fmt -- --check - cargo build --verbose --all - - cargo build --verbose --all --features async - cargo test --verbose --all - - cargo test --verbose --features async --example async_create_charge \ No newline at end of file + - cargo build --verbose --all --features async + - cargo test --verbose --features async --example async_create_charge + - cargo build --verbose --all --no-default-features diff --git a/Cargo.toml b/Cargo.toml index 6a346976..05ab649f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,27 +40,23 @@ full = [ # Stripe feature groups #core = [] # N.B. always enabled for now #payment-methods = [] # N.B. always enabled for now -checkout = ["unstable-everything-else"] -billing = ["unstable-everything-else"] -connect = ["unstable-everything-else"] -fraud = ["unstable-everything-else"] -issuing = ["unstable-everything-else"] -orders = ["unstable-everything-else"] -sigma = ["unstable-everything-else"] -webhook-endpoints = ["unstable-everything-else"] - -# Deprecated. Use either `webhook-events` or `webhook-endpoints` instead. -webhooks = ["webhook-endpoints", "webhook-events"] +checkout = [] +billing = [] +connect = [] +fraud = [] +issuing = [] +orders = [] +sigma = [] +webhook-endpoints = [] # Deserialize events from webhooks webhook-events = ["events", "hmac", "sha2"] events = [] -# Feature groups that haven't been broken out yet. -unstable-everything-else = [] # NOTE: Do not depend on this feature directly. +# Deprecated. Use either `webhook-events` or `webhook-endpoints` instead. +webhooks = ["webhook-endpoints", "webhook-events"] -# TODO: Deprecate `async` after we can use Generic Associated Types -# (see https://github.com/rust-lang/rust/issues/44265) +# Replace the sync client with an async client async = [] [dependencies] diff --git a/bench/dependecy_weight.toml b/bench/dependecy_weight.toml new file mode 100644 index 00000000..47df8936 --- /dev/null +++ b/bench/dependecy_weight.toml @@ -0,0 +1,29 @@ +## +## Example +## + +# [[benchmark]] +# commit = "d3be971826d775e7506352f2e63c59cd2a354525" +# profile = "debug" +# features = ["full"] +# hardware = "MacBook Air (13-inch, 2018)" +# time = { debug = "_m __s" } # as reported by `cargo build` +# size = { release = "___M" } # size of `.rlib` + +## +## Version: 0.12.0-alpha.1 +## + +[[benchmark]] +commit = "ce0ec0d2959f846808026c14f8ebbe8c26818c85" +hardware = "MacBook Air (13-inch, 2018)" +features = [] +time = { release = "10m 01s" } +size = { release = "43M", debug = "87M" } + +[[benchmark]] +commit = "d3be971826d775e7506352f2e63c59cd2a354525" +hardware = "MacBook Air (13-inch, 2018)" +features = ["full"] +time = { release = "12m 18s", debug = "4m 39s" } +size = { release = "92M", debug = "207M"} diff --git a/openapi/src/metadata.rs b/openapi/src/metadata.rs index 1e56d439..75b4edf5 100644 --- a/openapi/src/metadata.rs +++ b/openapi/src/metadata.rs @@ -49,7 +49,10 @@ pub fn feature_groups() -> BTreeMap<&'static str, &'static str> { ("account", "connect"), ("application", "connect"), ("application_fee", "connect"), + ("connect_collection_transfer", "connect"), + ("fee_refund", "connect"), ("person", "connect"), + ("recipient", "connect"), ("topup", "connect"), ("transfer", "connect"), ("transfer_reversal", "connect"), @@ -75,13 +78,8 @@ pub fn feature_groups() -> BTreeMap<&'static str, &'static str> { // Webhooks Endpoints ("webhook_endpoint", "webhook-endpoints"), - - // Etc. - ("connect_collection_transfer", "unstable-everything-else"), - ("fee_refund", "unstable-everything-else"), - ("recipient", "unstable-everything-else"), - ("source_transaction", "unstable-everything-else"), ] - .into_iter() - .copied() - .collect() + ] + .into_iter() + .copied() + .collect() } diff --git a/src/resources.rs b/src/resources.rs index 7ef0723a..e896da40 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -70,186 +70,199 @@ mod event; #[cfg(feature = "events")] pub use self::event::*; -// Unstable everything else -#[cfg(feature = "unstable-everything-else")] -mod account; -#[cfg(feature = "unstable-everything-else")] -mod application; -#[cfg(feature = "unstable-everything-else")] -mod application_fee; -#[cfg(feature = "unstable-everything-else")] +// Checkout +#[cfg(feature = "checkout")] mod checkout_session; -#[cfg(feature = "unstable-everything-else")] -mod connect_collection_transfer; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "checkout")] +pub use self::checkout_session::*; + +// Billing +#[cfg(feature = "billing")] mod coupon; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod discount; -#[cfg(feature = "unstable-everything-else")] -mod fee_refund; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod invoice; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod invoice_ext; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod invoiceitem; -#[cfg(feature = "unstable-everything-else")] -mod issuing_authorization; -#[cfg(feature = "unstable-everything-else")] -mod issuing_authorization_ext; -#[cfg(feature = "unstable-everything-else")] -mod issuing_card; -#[cfg(feature = "unstable-everything-else")] -mod issuing_card_ext; -#[cfg(feature = "unstable-everything-else")] -mod issuing_cardholder; -#[cfg(feature = "unstable-everything-else")] -mod issuing_dispute; -#[cfg(feature = "unstable-everything-else")] -mod issuing_dispute_ext; -#[cfg(feature = "unstable-everything-else")] -mod issuing_merchant_data; -#[cfg(feature = "unstable-everything-else")] -mod issuing_transaction; -#[cfg(feature = "unstable-everything-else")] -mod issuing_transaction_ext; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod line_item; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod line_item_ext; -#[cfg(feature = "unstable-everything-else")] -mod order; -#[cfg(feature = "unstable-everything-else")] -mod order_ext; -#[cfg(feature = "unstable-everything-else")] -mod order_item; -#[cfg(feature = "unstable-everything-else")] -mod order_return; -#[cfg(feature = "unstable-everything-else")] -mod person; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod plan; -#[cfg(feature = "unstable-everything-else")] -mod recipient; -#[cfg(feature = "unstable-everything-else")] -mod review; -#[cfg(feature = "unstable-everything-else")] -mod review_ext; -#[cfg(feature = "unstable-everything-else")] -mod scheduled_query_run; -#[cfg(feature = "unstable-everything-else")] -mod sku; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod subscription; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod subscription_ext; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod subscription_item; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod subscription_schedule; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod tax_id; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] mod tax_rate; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "billing")] +pub use self::coupon::*; +#[cfg(feature = "billing")] +pub use self::discount::*; +#[cfg(feature = "billing")] +pub use self::invoice::*; +#[cfg(feature = "billing")] +pub use self::invoice_ext::*; +#[cfg(feature = "billing")] +pub use self::invoiceitem::*; +#[cfg(feature = "billing")] +pub use self::line_item::*; +#[cfg(feature = "billing")] +pub use self::line_item_ext::*; +#[cfg(feature = "billing")] +pub use self::plan::*; +#[cfg(feature = "billing")] +pub use self::subscription::*; +#[cfg(feature = "billing")] +pub use self::subscription_ext::*; +#[cfg(feature = "billing")] +pub use self::subscription_item::*; +#[cfg(feature = "billing")] +pub use self::subscription_schedule::*; +#[cfg(feature = "billing")] +pub use self::tax_id::*; +#[cfg(feature = "billing")] +pub use self::tax_rate::*; + +// Connect +#[cfg(feature = "connect")] +mod account; +#[cfg(feature = "connect")] +mod application; +#[cfg(feature = "connect")] +mod application_fee; +#[cfg(feature = "connect")] +mod connect_collection_transfer; +#[cfg(feature = "connect")] +mod fee_refund; +#[cfg(feature = "connect")] +mod person; +#[cfg(feature = "connect")] +mod recipient; +#[cfg(feature = "connect")] mod topup; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] mod transfer; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] mod transfer_reversal; -#[cfg(feature = "unstable-everything-else")] -mod webhook_endpoint; -#[cfg(feature = "unstable-everything-else")] -mod webhook_endpoint_ext; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] pub use self::account::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] pub use self::application::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] pub use self::application_fee::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::checkout_session::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] pub use self::connect_collection_transfer::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::coupon::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::discount::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] pub use self::fee_refund::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::invoice::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::invoice_ext::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::invoiceitem::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "connect")] +pub use self::person::*; +#[cfg(feature = "connect")] +pub use self::recipient::*; +#[cfg(feature = "connect")] +pub use self::topup::*; +#[cfg(feature = "connect")] +pub use self::transfer::*; +#[cfg(feature = "connect")] +pub use self::transfer_reversal::*; + +// Fraud +#[cfg(feature = "fraud")] +mod review; +#[cfg(feature = "fraud")] +mod review_ext; +#[cfg(feature = "fraud")] +pub use self::review::*; +#[cfg(feature = "fraud")] +pub use self::review_ext::*; + +// Issuing +#[cfg(feature = "issuing")] +mod issuing_authorization; +#[cfg(feature = "issuing")] +mod issuing_authorization_ext; +#[cfg(feature = "issuing")] +mod issuing_card; +#[cfg(feature = "issuing")] +mod issuing_card_ext; +#[cfg(feature = "issuing")] +mod issuing_cardholder; +#[cfg(feature = "issuing")] +mod issuing_dispute; +#[cfg(feature = "issuing")] +mod issuing_dispute_ext; +#[cfg(feature = "issuing")] +mod issuing_merchant_data; +#[cfg(feature = "issuing")] +mod issuing_transaction; +#[cfg(feature = "issuing")] +mod issuing_transaction_ext; +#[cfg(feature = "issuing")] pub use self::issuing_authorization::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_authorization_ext::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_card::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_card_ext::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_cardholder::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_dispute::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_dispute_ext::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_merchant_data::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_transaction::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "issuing")] pub use self::issuing_transaction_ext::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::line_item::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::line_item_ext::*; -#[cfg(feature = "unstable-everything-else")] + +// Orders +#[cfg(feature = "orders")] +mod order; +#[cfg(feature = "orders")] +mod order_ext; +#[cfg(feature = "orders")] +mod order_item; +#[cfg(feature = "orders")] +mod order_return; +#[cfg(feature = "orders")] +mod sku; +#[cfg(feature = "orders")] pub use self::order::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "orders")] pub use self::order_ext::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "orders")] pub use self::order_item::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "orders")] pub use self::order_return::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::person::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::plan::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::recipient::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::review::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::review_ext::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::scheduled_query_run::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "orders")] pub use self::sku::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::subscription::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::subscription_ext::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::subscription_item::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::subscription_schedule::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::tax_id::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::tax_rate::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::topup::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::transfer::*; -#[cfg(feature = "unstable-everything-else")] -pub use self::transfer_reversal::*; -#[cfg(feature = "unstable-everything-else")] + +#[cfg(feature = "sigma")] +mod scheduled_query_run; +#[cfg(feature = "sigma")] +pub use self::scheduled_query_run::*; + +// Not-yet-implemented feature flags +#[cfg(feature = "webhook-endpoints")] +mod webhook_endpoint; +#[cfg(feature = "webhook-endpoints")] +mod webhook_endpoint_ext; +#[cfg(feature = "webhook-endpoints")] pub use self::webhook_endpoint::*; -#[cfg(feature = "unstable-everything-else")] +#[cfg(feature = "webhook-endpoints")] pub use self::webhook_endpoint_ext::*; // Fallback types diff --git a/src/resources/placeholders.rs b/src/resources/placeholders.rs index 8d4a794f..10dade45 100644 --- a/src/resources/placeholders.rs +++ b/src/resources/placeholders.rs @@ -70,13 +70,13 @@ impl Object for CheckoutSession { } } -#[cfg(not(feature = "unstable-everything-else"))] +#[cfg(not(feature = "connect"))] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ConnectCollectionTransfer { pub id: (), } -#[cfg(not(feature = "unstable-everything-else"))] +#[cfg(not(feature = "connect"))] impl Object for ConnectCollectionTransfer { type Id = (); fn id(&self) -> Self::Id { @@ -121,13 +121,13 @@ impl Object for Discount { } } -#[cfg(not(feature = "unstable-everything-else"))] +#[cfg(not(feature = "connect"))] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ApplicationFeeRefund { pub id: ApplicationFeeRefundId, } -#[cfg(not(feature = "unstable-everything-else"))] +#[cfg(not(feature = "connect"))] impl Object for ApplicationFeeRefund { type Id = ApplicationFeeRefundId; fn id(&self) -> Self::Id { @@ -359,13 +359,13 @@ impl Object for Plan { } } -#[cfg(not(feature = "unstable-everything-else"))] +#[cfg(not(feature = "connect"))] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Recipient { pub id: RecipientId, } -#[cfg(not(feature = "unstable-everything-else"))] +#[cfg(not(feature = "connect"))] impl Object for Recipient { type Id = RecipientId; fn id(&self) -> Self::Id { @@ -427,23 +427,6 @@ impl Object for Sku { } } -#[cfg(not(feature = "unstable-everything-else"))] -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct SourceTransaction { - pub id: ChargeId, -} - -#[cfg(not(feature = "unstable-everything-else"))] -impl Object for SourceTransaction { - type Id = ChargeId; - fn id(&self) -> Self::Id { - self.id.clone() - } - fn object(&self) -> &'static str { - "source_transaction" - } -} - #[cfg(not(feature = "billing"))] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Subscription {