From ccb9570540eb77317a8b52920d77b0ec5fff70b9 Mon Sep 17 00:00:00 2001 From: Matthew Zeitlin <37011898+mzeitlin11@users.noreply.github.com> Date: Sun, 17 Dec 2023 16:31:39 -0500 Subject: [PATCH] Add back AsCursor trait and clean up Expandable removed id method --- CHANGELOG.md | 2 + Cargo.toml | 2 +- async-stripe/src/pagination.rs | 7 ++-- .../src/billing_portal_configuration/mod.rs | 4 +- .../src/billing_portal_session/mod.rs | 4 +- .../mod.rs | 4 +- .../stripe_billing/src/usage_record/mod.rs | 4 +- .../src/checkout_session/mod.rs | 4 +- .../stripe_connect/src/apps_secret/mod.rs | 4 +- .../stripe_connect/src/country_spec/mod.rs | 4 +- generated/stripe_core/src/token/mod.rs | 4 +- .../src/deleted_radar_value_list/mod.rs | 4 +- .../src/deleted_radar_value_list_item/mod.rs | 4 +- .../src/radar_early_fraud_warning/mod.rs | 4 +- .../stripe_fraud/src/radar_value_list/mod.rs | 4 +- .../src/radar_value_list_item/mod.rs | 4 +- .../stripe_misc/src/apple_pay_domain/mod.rs | 4 +- .../src/deleted_apple_pay_domain/mod.rs | 4 +- .../src/deleted_webhook_endpoint/mod.rs | 4 +- .../stripe_misc/src/ephemeral_key/mod.rs | 4 +- .../stripe_misc/src/exchange_rate/mod.rs | 4 +- .../src/financial_connections_account/mod.rs | 4 +- .../mod.rs | 4 +- .../mod.rs | 4 +- .../src/financial_connections_session/mod.rs | 4 +- .../src/identity_verification_report/mod.rs | 4 +- .../src/identity_verification_session/mod.rs | 4 +- .../src/reporting_report_run/mod.rs | 4 +- .../src/reporting_report_type/mod.rs | 4 +- .../src/scheduled_query_run/mod.rs | 4 +- .../stripe_misc/src/tax_calculation/mod.rs | 4 +- .../src/tax_calculation_line_item/mod.rs | 4 +- .../stripe_misc/src/tax_registration/mod.rs | 4 +- .../stripe_misc/src/tax_transaction/mod.rs | 4 +- .../src/tax_transaction_line_item/mod.rs | 4 +- .../stripe_misc/src/webhook_endpoint/mod.rs | 4 +- .../src/payment_method_configuration/mod.rs | 4 +- .../src/payment_method_domain/mod.rs | 4 +- generated/stripe_shared/src/account/mod.rs | 4 +- .../stripe_shared/src/application/mod.rs | 4 +- .../stripe_shared/src/application_fee/mod.rs | 4 +- .../src/application_fee_refund/mod.rs | 4 +- .../src/balance_transaction/mod.rs | 4 +- .../src/balance_transaction_source/mod.rs | 38 +++++++++---------- .../stripe_shared/src/bank_account/mod.rs | 4 +- generated/stripe_shared/src/capability/mod.rs | 4 +- generated/stripe_shared/src/card/mod.rs | 4 +- generated/stripe_shared/src/charge/mod.rs | 4 +- .../src/checkout_session_item/mod.rs | 4 +- .../src/connect_collection_transfer/mod.rs | 4 +- generated/stripe_shared/src/coupon/mod.rs | 4 +- .../stripe_shared/src/credit_note/mod.rs | 4 +- .../src/credit_note_line_item/mod.rs | 4 +- generated/stripe_shared/src/customer/mod.rs | 4 +- .../src/customer_balance_transaction/mod.rs | 4 +- .../customer_cash_balance_transaction/mod.rs | 4 +- .../stripe_shared/src/deleted_account/mod.rs | 4 +- .../src/deleted_bank_account/mod.rs | 4 +- .../stripe_shared/src/deleted_card/mod.rs | 4 +- .../stripe_shared/src/deleted_coupon/mod.rs | 4 +- .../stripe_shared/src/deleted_customer/mod.rs | 4 +- .../stripe_shared/src/deleted_discount/mod.rs | 4 +- .../src/deleted_external_account/mod.rs | 8 ++-- .../stripe_shared/src/deleted_invoice/mod.rs | 4 +- .../src/deleted_invoiceitem/mod.rs | 4 +- .../src/deleted_payment_source/mod.rs | 8 ++-- .../stripe_shared/src/deleted_person/mod.rs | 4 +- .../stripe_shared/src/deleted_plan/mod.rs | 4 +- .../stripe_shared/src/deleted_product/mod.rs | 4 +- .../src/deleted_subscription_item/mod.rs | 4 +- .../stripe_shared/src/deleted_tax_id/mod.rs | 4 +- .../deleted_test_helpers_test_clock/mod.rs | 4 +- generated/stripe_shared/src/discount/mod.rs | 4 +- generated/stripe_shared/src/dispute/mod.rs | 4 +- generated/stripe_shared/src/event/mod.rs | 4 +- .../stripe_shared/src/external_account/mod.rs | 8 ++-- generated/stripe_shared/src/file/mod.rs | 4 +- generated/stripe_shared/src/file_link/mod.rs | 4 +- generated/stripe_shared/src/invoice/mod.rs | 4 +- .../stripe_shared/src/invoice_item/mod.rs | 4 +- .../src/invoice_line_item/mod.rs | 4 +- .../src/issuing_authorization/mod.rs | 4 +- .../stripe_shared/src/issuing_card/mod.rs | 4 +- .../src/issuing_cardholder/mod.rs | 4 +- .../stripe_shared/src/issuing_dispute/mod.rs | 4 +- .../stripe_shared/src/issuing_token/mod.rs | 4 +- .../src/issuing_transaction/mod.rs | 4 +- generated/stripe_shared/src/mandate/mod.rs | 4 +- .../stripe_shared/src/payment_intent/mod.rs | 4 +- .../stripe_shared/src/payment_link/mod.rs | 4 +- .../stripe_shared/src/payment_method/mod.rs | 4 +- .../stripe_shared/src/payment_source/mod.rs | 12 +++--- generated/stripe_shared/src/payout/mod.rs | 4 +- generated/stripe_shared/src/person/mod.rs | 4 +- generated/stripe_shared/src/plan/mod.rs | 4 +- .../stripe_shared/src/platform_tax_fee/mod.rs | 4 +- generated/stripe_shared/src/price/mod.rs | 4 +- generated/stripe_shared/src/product/mod.rs | 4 +- .../stripe_shared/src/promotion_code/mod.rs | 4 +- generated/stripe_shared/src/quote/mod.rs | 4 +- generated/stripe_shared/src/refund/mod.rs | 4 +- .../src/reserve_transaction/mod.rs | 4 +- generated/stripe_shared/src/review/mod.rs | 4 +- generated/stripe_shared/src/rule/mod.rs | 4 +- .../stripe_shared/src/setup_attempt/mod.rs | 4 +- .../stripe_shared/src/setup_intent/mod.rs | 4 +- .../stripe_shared/src/shipping_rate/mod.rs | 4 +- generated/stripe_shared/src/source/mod.rs | 4 +- .../src/source_transaction/mod.rs | 4 +- .../stripe_shared/src/subscription/mod.rs | 4 +- .../src/subscription_item/mod.rs | 4 +- .../src/subscription_schedule/mod.rs | 4 +- generated/stripe_shared/src/tax_code/mod.rs | 4 +- .../src/tax_deducted_at_source/mod.rs | 4 +- generated/stripe_shared/src/tax_id/mod.rs | 4 +- generated/stripe_shared/src/tax_rate/mod.rs | 4 +- .../src/test_helpers_test_clock/mod.rs | 4 +- generated/stripe_shared/src/topup/mod.rs | 4 +- generated/stripe_shared/src/transfer/mod.rs | 4 +- .../src/transfer_reversal/mod.rs | 4 +- .../src/usage_record_summary/mod.rs | 4 +- .../src/deleted_terminal_configuration/mod.rs | 4 +- .../src/deleted_terminal_location/mod.rs | 4 +- .../src/deleted_terminal_reader/mod.rs | 4 +- .../src/terminal_configuration/mod.rs | 4 +- .../src/terminal_location/mod.rs | 4 +- .../src/terminal_reader/mod.rs | 4 +- .../src/treasury_credit_reversal/mod.rs | 4 +- .../src/treasury_debit_reversal/mod.rs | 4 +- .../src/treasury_financial_account/mod.rs | 4 +- .../src/treasury_inbound_transfer/mod.rs | 4 +- .../src/treasury_outbound_payment/mod.rs | 4 +- .../src/treasury_outbound_transfer/mod.rs | 4 +- .../src/treasury_received_credit/mod.rs | 4 +- .../src/treasury_received_debit/mod.rs | 4 +- .../src/treasury_transaction/mod.rs | 4 +- .../src/treasury_transaction_entry/mod.rs | 4 +- openapi/src/object_writing.rs | 6 +-- openapi/src/templates/object_trait.rs | 19 +++------- stripe_types/src/expandable.rs | 7 ++++ stripe_types/src/ids.rs | 24 ++++++++++++ stripe_types/src/pagination.rs | 30 ++++++++++++++- 142 files changed, 369 insertions(+), 318 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49a4dbe53..9c8bcd534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,8 @@ implementations. Please let us know if such implementations are useful, and they they stay up to date, preventing errors error deserialization errors like (https://github.com/arlyon/async-stripe/issues/381) and (https://github.com/arlyon/async-stripe/issues/384) - The main user-facing change will be `StripeError::Stripe(RequestError)` -> `StripeError::Stripe(ApiErrors, StatusCode)` since the autogenerated `ApiErrors` does not include the status code. +- The `id` method on `Expandable` now returns a reference: `&T::Id`. All id types implement `Clone` so +to achieve the previous behavior, use `.id().clone()`. Since most of these changes are related to code generation, it is likely there are some breaking changes we missed here. If so, please open an issue (especially for changes that degrade library ergonomics). diff --git a/Cargo.toml b/Cargo.toml index c8e8e4d01..eb7f3960b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,5 +38,5 @@ edition = "2021" [workspace.dependencies] serde = {version = ">=1.0.79", features = ["derive"] } # we use `serde(other)` which was introduced in 1.0.79 http-types = { version = "2.12.0", default-features = false } -smol_str = "0.2.0" +smol_str = { version = "0.2.0", features = ["serde"] } serde_json = "1.0" \ No newline at end of file diff --git a/async-stripe/src/pagination.rs b/async-stripe/src/pagination.rs index 3deccf29f..b4581bf03 100644 --- a/async-stripe/src/pagination.rs +++ b/async-stripe/src/pagination.rs @@ -2,7 +2,7 @@ #![allow(clippy::missing_errors_doc)] use serde::de::DeserializeOwned; use serde::Serialize; -use stripe_types::{List, Object}; +use stripe_types::{AsCursorOpt, List, Object}; use crate::{Client, Response}; @@ -27,6 +27,7 @@ pub trait PaginationExt { impl PaginationExt for List where T: Object + DeserializeOwned + Send + Sync + 'static, + T::Id: ToString, { fn into_paginator(self) -> ListPaginator { let mut paginator = ListPaginator { @@ -37,7 +38,7 @@ where total_count: self.total_count, params: Default::default(), }; - if let Some(curr_cursor) = paginator.data.last().and_then(|t| t.id()) { + if let Some(curr_cursor) = paginator.data.last().and_then(|t| t.id().as_cursor_opt()) { paginator.update_cursor(curr_cursor.to_string()); } paginator @@ -147,7 +148,7 @@ where fn update_with_new_data(&mut self, list: List) { self.has_more = list.has_more; self.total_count = list.total_count; - if let Some(new_cursor) = list.data.last().and_then(|l| l.id()) { + if let Some(new_cursor) = list.data.last().and_then(|l| l.id().as_cursor_opt()) { self.update_cursor(new_cursor.to_string()); } else { self.has_more = false; diff --git a/generated/stripe_billing/src/billing_portal_configuration/mod.rs b/generated/stripe_billing/src/billing_portal_configuration/mod.rs index 394360b6d..c3a1e600e 100644 --- a/generated/stripe_billing/src/billing_portal_configuration/mod.rs +++ b/generated/stripe_billing/src/billing_portal_configuration/mod.rs @@ -35,8 +35,8 @@ pub struct BillingPortalConfiguration { } impl stripe_types::Object for BillingPortalConfiguration { type Id = stripe_billing::billing_portal_configuration::BillingPortalConfigurationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(BillingPortalConfigurationId, "bpc_"); diff --git a/generated/stripe_billing/src/billing_portal_session/mod.rs b/generated/stripe_billing/src/billing_portal_session/mod.rs index f4a47ce01..fdca605e6 100644 --- a/generated/stripe_billing/src/billing_portal_session/mod.rs +++ b/generated/stripe_billing/src/billing_portal_session/mod.rs @@ -243,8 +243,8 @@ impl<'de> serde::Deserialize<'de> for BillingPortalSessionLocale { } impl stripe_types::Object for BillingPortalSession { type Id = stripe_billing::billing_portal_session::BillingPortalSessionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(BillingPortalSessionId, "bps_"); diff --git a/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item/mod.rs b/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item/mod.rs index e047acc33..d17577ac6 100644 --- a/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item/mod.rs +++ b/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item/mod.rs @@ -13,8 +13,8 @@ pub quantity: Option, } impl stripe_types::Object for PortalFlowsSubscriptionUpdateConfirmItem { type Id = Option; - fn id(&self) -> Option<&str> { - self.id.as_deref() + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PortalFlowsSubscriptionUpdateConfirmItemId); diff --git a/generated/stripe_billing/src/usage_record/mod.rs b/generated/stripe_billing/src/usage_record/mod.rs index 44428a8fb..8ba813708 100644 --- a/generated/stripe_billing/src/usage_record/mod.rs +++ b/generated/stripe_billing/src/usage_record/mod.rs @@ -17,8 +17,8 @@ pub struct UsageRecord { } impl stripe_types::Object for UsageRecord { type Id = stripe_billing::usage_record::UsageRecordId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(UsageRecordId, "mbur_"); diff --git a/generated/stripe_checkout/src/checkout_session/mod.rs b/generated/stripe_checkout/src/checkout_session/mod.rs index 4d221f9af..a1d231b32 100644 --- a/generated/stripe_checkout/src/checkout_session/mod.rs +++ b/generated/stripe_checkout/src/checkout_session/mod.rs @@ -902,8 +902,8 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionUiMode { } impl stripe_types::Object for CheckoutSession { type Id = stripe_checkout::checkout_session::CheckoutSessionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CheckoutSessionId, "cs_"); diff --git a/generated/stripe_connect/src/apps_secret/mod.rs b/generated/stripe_connect/src/apps_secret/mod.rs index 2145350fe..b21ac572a 100644 --- a/generated/stripe_connect/src/apps_secret/mod.rs +++ b/generated/stripe_connect/src/apps_secret/mod.rs @@ -29,8 +29,8 @@ pub struct AppsSecret { } impl stripe_types::Object for AppsSecret { type Id = stripe_connect::apps_secret::AppsSecretId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(AppsSecretId); diff --git a/generated/stripe_connect/src/country_spec/mod.rs b/generated/stripe_connect/src/country_spec/mod.rs index 2be74d2c2..40ea5d454 100644 --- a/generated/stripe_connect/src/country_spec/mod.rs +++ b/generated/stripe_connect/src/country_spec/mod.rs @@ -28,8 +28,8 @@ pub struct CountrySpec { } impl stripe_types::Object for CountrySpec { type Id = stripe_connect::country_spec::CountrySpecId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CountrySpecId); diff --git a/generated/stripe_core/src/token/mod.rs b/generated/stripe_core/src/token/mod.rs index a14ca52b2..142bb5c62 100644 --- a/generated/stripe_core/src/token/mod.rs +++ b/generated/stripe_core/src/token/mod.rs @@ -32,8 +32,8 @@ pub struct Token { } impl stripe_types::Object for Token { type Id = stripe_core::token::TokenId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TokenId); diff --git a/generated/stripe_fraud/src/deleted_radar_value_list/mod.rs b/generated/stripe_fraud/src/deleted_radar_value_list/mod.rs index 437d1ae65..d2f32d745 100644 --- a/generated/stripe_fraud/src/deleted_radar_value_list/mod.rs +++ b/generated/stripe_fraud/src/deleted_radar_value_list/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedRadarValueList { } impl stripe_types::Object for DeletedRadarValueList { type Id = stripe_fraud::radar_value_list::RadarValueListId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_fraud/src/deleted_radar_value_list_item/mod.rs b/generated/stripe_fraud/src/deleted_radar_value_list_item/mod.rs index 795077cfc..7193c005e 100644 --- a/generated/stripe_fraud/src/deleted_radar_value_list_item/mod.rs +++ b/generated/stripe_fraud/src/deleted_radar_value_list_item/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedRadarValueListItem { } impl stripe_types::Object for DeletedRadarValueListItem { type Id = stripe_fraud::radar_value_list_item::RadarValueListItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_fraud/src/radar_early_fraud_warning/mod.rs b/generated/stripe_fraud/src/radar_early_fraud_warning/mod.rs index 039b1810d..2e65bb260 100644 --- a/generated/stripe_fraud/src/radar_early_fraud_warning/mod.rs +++ b/generated/stripe_fraud/src/radar_early_fraud_warning/mod.rs @@ -28,8 +28,8 @@ pub struct RadarEarlyFraudWarning { } impl stripe_types::Object for RadarEarlyFraudWarning { type Id = stripe_fraud::radar_early_fraud_warning::RadarEarlyFraudWarningId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(RadarEarlyFraudWarningId); diff --git a/generated/stripe_fraud/src/radar_value_list/mod.rs b/generated/stripe_fraud/src/radar_value_list/mod.rs index 134af4434..b5041571d 100644 --- a/generated/stripe_fraud/src/radar_value_list/mod.rs +++ b/generated/stripe_fraud/src/radar_value_list/mod.rs @@ -115,8 +115,8 @@ impl<'de> serde::Deserialize<'de> for RadarValueListItemType { } impl stripe_types::Object for RadarValueList { type Id = stripe_fraud::radar_value_list::RadarValueListId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(RadarValueListId); diff --git a/generated/stripe_fraud/src/radar_value_list_item/mod.rs b/generated/stripe_fraud/src/radar_value_list_item/mod.rs index cf8d15436..a4d793052 100644 --- a/generated/stripe_fraud/src/radar_value_list_item/mod.rs +++ b/generated/stripe_fraud/src/radar_value_list_item/mod.rs @@ -20,8 +20,8 @@ pub struct RadarValueListItem { } impl stripe_types::Object for RadarValueListItem { type Id = stripe_fraud::radar_value_list_item::RadarValueListItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(RadarValueListItemId); diff --git a/generated/stripe_misc/src/apple_pay_domain/mod.rs b/generated/stripe_misc/src/apple_pay_domain/mod.rs index dba1853b3..94140737b 100644 --- a/generated/stripe_misc/src/apple_pay_domain/mod.rs +++ b/generated/stripe_misc/src/apple_pay_domain/mod.rs @@ -12,8 +12,8 @@ pub struct ApplePayDomain { } impl stripe_types::Object for ApplePayDomain { type Id = stripe_misc::apple_pay_domain::ApplePayDomainId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ApplePayDomainId); diff --git a/generated/stripe_misc/src/deleted_apple_pay_domain/mod.rs b/generated/stripe_misc/src/deleted_apple_pay_domain/mod.rs index 93c21ea0c..ae6fe3937 100644 --- a/generated/stripe_misc/src/deleted_apple_pay_domain/mod.rs +++ b/generated/stripe_misc/src/deleted_apple_pay_domain/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedApplePayDomain { } impl stripe_types::Object for DeletedApplePayDomain { type Id = stripe_misc::apple_pay_domain::ApplePayDomainId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_misc/src/deleted_webhook_endpoint/mod.rs b/generated/stripe_misc/src/deleted_webhook_endpoint/mod.rs index aea5f7180..6e6f1449f 100644 --- a/generated/stripe_misc/src/deleted_webhook_endpoint/mod.rs +++ b/generated/stripe_misc/src/deleted_webhook_endpoint/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedWebhookEndpoint { } impl stripe_types::Object for DeletedWebhookEndpoint { type Id = stripe_misc::webhook_endpoint::WebhookEndpointId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_misc/src/ephemeral_key/mod.rs b/generated/stripe_misc/src/ephemeral_key/mod.rs index 2eab9b120..d1e8cc43c 100644 --- a/generated/stripe_misc/src/ephemeral_key/mod.rs +++ b/generated/stripe_misc/src/ephemeral_key/mod.rs @@ -20,8 +20,8 @@ pub struct EphemeralKey { } impl stripe_types::Object for EphemeralKey { type Id = stripe_misc::ephemeral_key::EphemeralKeyId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(EphemeralKeyId, "ephkey_"); diff --git a/generated/stripe_misc/src/exchange_rate/mod.rs b/generated/stripe_misc/src/exchange_rate/mod.rs index f7ddcfa65..1d2dc6ea9 100644 --- a/generated/stripe_misc/src/exchange_rate/mod.rs +++ b/generated/stripe_misc/src/exchange_rate/mod.rs @@ -18,8 +18,8 @@ pub struct ExchangeRate { } impl stripe_types::Object for ExchangeRate { type Id = stripe_misc::exchange_rate::ExchangeRateId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ExchangeRateId); diff --git a/generated/stripe_misc/src/financial_connections_account/mod.rs b/generated/stripe_misc/src/financial_connections_account/mod.rs index 473721235..d27d7a74e 100644 --- a/generated/stripe_misc/src/financial_connections_account/mod.rs +++ b/generated/stripe_misc/src/financial_connections_account/mod.rs @@ -400,8 +400,8 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountSupportedPaymen } impl stripe_types::Object for FinancialConnectionsAccount { type Id = stripe_misc::financial_connections_account::FinancialConnectionsAccountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(FinancialConnectionsAccountId); diff --git a/generated/stripe_misc/src/financial_connections_account_owner/mod.rs b/generated/stripe_misc/src/financial_connections_account_owner/mod.rs index 4029c86de..f2035e72b 100644 --- a/generated/stripe_misc/src/financial_connections_account_owner/mod.rs +++ b/generated/stripe_misc/src/financial_connections_account_owner/mod.rs @@ -18,8 +18,8 @@ pub struct FinancialConnectionsAccountOwner { } impl stripe_types::Object for FinancialConnectionsAccountOwner { type Id = stripe_misc::financial_connections_account_owner::FinancialConnectionsAccountOwnerId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(FinancialConnectionsAccountOwnerId); diff --git a/generated/stripe_misc/src/financial_connections_account_ownership/mod.rs b/generated/stripe_misc/src/financial_connections_account_ownership/mod.rs index dfdb5721f..9b1b82f06 100644 --- a/generated/stripe_misc/src/financial_connections_account_ownership/mod.rs +++ b/generated/stripe_misc/src/financial_connections_account_ownership/mod.rs @@ -13,8 +13,8 @@ pub owners: stripe_types::List, } impl stripe_types::Object for FinancialConnectionsAccountOwnership { type Id = stripe_misc::financial_connections_account_ownership::FinancialConnectionsAccountOwnershipId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(FinancialConnectionsAccountOwnershipId); diff --git a/generated/stripe_misc/src/financial_connections_session/mod.rs b/generated/stripe_misc/src/financial_connections_session/mod.rs index 871c1b7c9..ebc69b071 100644 --- a/generated/stripe_misc/src/financial_connections_session/mod.rs +++ b/generated/stripe_misc/src/financial_connections_session/mod.rs @@ -151,8 +151,8 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsSessionPrefetch { } impl stripe_types::Object for FinancialConnectionsSession { type Id = stripe_misc::financial_connections_session::FinancialConnectionsSessionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(FinancialConnectionsSessionId); diff --git a/generated/stripe_misc/src/identity_verification_report/mod.rs b/generated/stripe_misc/src/identity_verification_report/mod.rs index 7f9ded5d3..38825e932 100644 --- a/generated/stripe_misc/src/identity_verification_report/mod.rs +++ b/generated/stripe_misc/src/identity_verification_report/mod.rs @@ -91,8 +91,8 @@ impl<'de> serde::Deserialize<'de> for IdentityVerificationReportType { } impl stripe_types::Object for IdentityVerificationReport { type Id = stripe_misc::identity_verification_report::IdentityVerificationReportId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IdentityVerificationReportId); diff --git a/generated/stripe_misc/src/identity_verification_session/mod.rs b/generated/stripe_misc/src/identity_verification_session/mod.rs index 1d9e85b50..16260969c 100644 --- a/generated/stripe_misc/src/identity_verification_session/mod.rs +++ b/generated/stripe_misc/src/identity_verification_session/mod.rs @@ -184,8 +184,8 @@ impl<'de> serde::Deserialize<'de> for IdentityVerificationSessionType { } impl stripe_types::Object for IdentityVerificationSession { type Id = stripe_misc::identity_verification_session::IdentityVerificationSessionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IdentityVerificationSessionId); diff --git a/generated/stripe_misc/src/reporting_report_run/mod.rs b/generated/stripe_misc/src/reporting_report_run/mod.rs index 5fee5c9c4..15bb94891 100644 --- a/generated/stripe_misc/src/reporting_report_run/mod.rs +++ b/generated/stripe_misc/src/reporting_report_run/mod.rs @@ -34,8 +34,8 @@ pub struct ReportingReportRun { } impl stripe_types::Object for ReportingReportRun { type Id = stripe_misc::reporting_report_run::ReportingReportRunId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ReportingReportRunId); diff --git a/generated/stripe_misc/src/reporting_report_type/mod.rs b/generated/stripe_misc/src/reporting_report_type/mod.rs index b4d13fa3e..e01f4ad05 100644 --- a/generated/stripe_misc/src/reporting_report_type/mod.rs +++ b/generated/stripe_misc/src/reporting_report_type/mod.rs @@ -34,8 +34,8 @@ pub struct ReportingReportType { } impl stripe_types::Object for ReportingReportType { type Id = stripe_misc::reporting_report_type::ReportingReportTypeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ReportingReportTypeId); diff --git a/generated/stripe_misc/src/scheduled_query_run/mod.rs b/generated/stripe_misc/src/scheduled_query_run/mod.rs index 7c82a1d96..c4ea1ab42 100644 --- a/generated/stripe_misc/src/scheduled_query_run/mod.rs +++ b/generated/stripe_misc/src/scheduled_query_run/mod.rs @@ -30,8 +30,8 @@ pub struct ScheduledQueryRun { } impl stripe_types::Object for ScheduledQueryRun { type Id = stripe_misc::scheduled_query_run::ScheduledQueryRunId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ScheduledQueryRunId, "sqr_"); diff --git a/generated/stripe_misc/src/tax_calculation/mod.rs b/generated/stripe_misc/src/tax_calculation/mod.rs index 14ac62530..ffd43a5dd 100644 --- a/generated/stripe_misc/src/tax_calculation/mod.rs +++ b/generated/stripe_misc/src/tax_calculation/mod.rs @@ -33,8 +33,8 @@ pub struct TaxCalculation { } impl stripe_types::Object for TaxCalculation { type Id = Option; - fn id(&self) -> Option<&str> { - self.id.as_deref() + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxCalculationId); diff --git a/generated/stripe_misc/src/tax_calculation_line_item/mod.rs b/generated/stripe_misc/src/tax_calculation_line_item/mod.rs index c08fc64bf..bec7992d1 100644 --- a/generated/stripe_misc/src/tax_calculation_line_item/mod.rs +++ b/generated/stripe_misc/src/tax_calculation_line_item/mod.rs @@ -92,8 +92,8 @@ impl<'de> serde::Deserialize<'de> for TaxCalculationLineItemTaxBehavior { } impl stripe_types::Object for TaxCalculationLineItem { type Id = stripe_misc::tax_calculation_line_item::TaxCalculationLineItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxCalculationLineItemId); diff --git a/generated/stripe_misc/src/tax_registration/mod.rs b/generated/stripe_misc/src/tax_registration/mod.rs index 7410c7e78..f005b4ae8 100644 --- a/generated/stripe_misc/src/tax_registration/mod.rs +++ b/generated/stripe_misc/src/tax_registration/mod.rs @@ -96,8 +96,8 @@ impl<'de> serde::Deserialize<'de> for TaxRegistrationStatus { } impl stripe_types::Object for TaxRegistration { type Id = stripe_misc::tax_registration::TaxRegistrationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxRegistrationId); diff --git a/generated/stripe_misc/src/tax_transaction/mod.rs b/generated/stripe_misc/src/tax_transaction/mod.rs index 9285873cb..816602aa1 100644 --- a/generated/stripe_misc/src/tax_transaction/mod.rs +++ b/generated/stripe_misc/src/tax_transaction/mod.rs @@ -97,8 +97,8 @@ impl<'de> serde::Deserialize<'de> for TaxTransactionType { } impl stripe_types::Object for TaxTransaction { type Id = stripe_misc::tax_transaction::TaxTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxTransactionId); diff --git a/generated/stripe_misc/src/tax_transaction_line_item/mod.rs b/generated/stripe_misc/src/tax_transaction_line_item/mod.rs index ab5a85962..5ba28e192 100644 --- a/generated/stripe_misc/src/tax_transaction_line_item/mod.rs +++ b/generated/stripe_misc/src/tax_transaction_line_item/mod.rs @@ -158,8 +158,8 @@ impl<'de> serde::Deserialize<'de> for TaxTransactionLineItemType { } impl stripe_types::Object for TaxTransactionLineItem { type Id = stripe_misc::tax_transaction_line_item::TaxTransactionLineItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxTransactionLineItemId); diff --git a/generated/stripe_misc/src/webhook_endpoint/mod.rs b/generated/stripe_misc/src/webhook_endpoint/mod.rs index 9843828bf..486757e50 100644 --- a/generated/stripe_misc/src/webhook_endpoint/mod.rs +++ b/generated/stripe_misc/src/webhook_endpoint/mod.rs @@ -43,8 +43,8 @@ pub struct WebhookEndpoint { } impl stripe_types::Object for WebhookEndpoint { type Id = stripe_misc::webhook_endpoint::WebhookEndpointId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(WebhookEndpointId, "we_"); diff --git a/generated/stripe_payment/src/payment_method_configuration/mod.rs b/generated/stripe_payment/src/payment_method_configuration/mod.rs index 0365f38f1..cf475fdcc 100644 --- a/generated/stripe_payment/src/payment_method_configuration/mod.rs +++ b/generated/stripe_payment/src/payment_method_configuration/mod.rs @@ -100,8 +100,8 @@ pub struct PaymentMethodConfiguration { } impl stripe_types::Object for PaymentMethodConfiguration { type Id = stripe_payment::payment_method_configuration::PaymentMethodConfigurationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PaymentMethodConfigurationId); diff --git a/generated/stripe_payment/src/payment_method_domain/mod.rs b/generated/stripe_payment/src/payment_method_domain/mod.rs index 31e537419..2a6379882 100644 --- a/generated/stripe_payment/src/payment_method_domain/mod.rs +++ b/generated/stripe_payment/src/payment_method_domain/mod.rs @@ -25,8 +25,8 @@ pub struct PaymentMethodDomain { } impl stripe_types::Object for PaymentMethodDomain { type Id = stripe_payment::payment_method_domain::PaymentMethodDomainId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PaymentMethodDomainId); diff --git a/generated/stripe_shared/src/account/mod.rs b/generated/stripe_shared/src/account/mod.rs index 230ba0c93..4eaa55961 100644 --- a/generated/stripe_shared/src/account/mod.rs +++ b/generated/stripe_shared/src/account/mod.rs @@ -206,8 +206,8 @@ impl<'de> serde::Deserialize<'de> for AccountType { } impl stripe_types::Object for Account { type Id = stripe_shared::account::AccountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(AccountId, "acct_"); diff --git a/generated/stripe_shared/src/application/mod.rs b/generated/stripe_shared/src/application/mod.rs index c026d1674..c6dd9042c 100644 --- a/generated/stripe_shared/src/application/mod.rs +++ b/generated/stripe_shared/src/application/mod.rs @@ -7,8 +7,8 @@ pub struct Application { } impl stripe_types::Object for Application { type Id = stripe_shared::application::ApplicationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ApplicationId, "ca_"); diff --git a/generated/stripe_shared/src/application_fee/mod.rs b/generated/stripe_shared/src/application_fee/mod.rs index 07920ea27..4b875eb7c 100644 --- a/generated/stripe_shared/src/application_fee/mod.rs +++ b/generated/stripe_shared/src/application_fee/mod.rs @@ -35,8 +35,8 @@ pub struct ApplicationFee { } impl stripe_types::Object for ApplicationFee { type Id = stripe_shared::application_fee::ApplicationFeeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ApplicationFeeId, "fee_"); diff --git a/generated/stripe_shared/src/application_fee_refund/mod.rs b/generated/stripe_shared/src/application_fee_refund/mod.rs index 32efeaca0..aa20c3b06 100644 --- a/generated/stripe_shared/src/application_fee_refund/mod.rs +++ b/generated/stripe_shared/src/application_fee_refund/mod.rs @@ -27,8 +27,8 @@ pub struct ApplicationFeeRefund { } impl stripe_types::Object for ApplicationFeeRefund { type Id = stripe_shared::application_fee_refund::ApplicationFeeRefundId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ApplicationFeeRefundId, "fr_"); diff --git a/generated/stripe_shared/src/balance_transaction/mod.rs b/generated/stripe_shared/src/balance_transaction/mod.rs index 1489483f0..e32ecf0f4 100644 --- a/generated/stripe_shared/src/balance_transaction/mod.rs +++ b/generated/stripe_shared/src/balance_transaction/mod.rs @@ -235,8 +235,8 @@ impl<'de> serde::Deserialize<'de> for BalanceTransactionType { } impl stripe_types::Object for BalanceTransaction { type Id = stripe_shared::balance_transaction::BalanceTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(BalanceTransactionId, "txn_"); diff --git a/generated/stripe_shared/src/balance_transaction_source/mod.rs b/generated/stripe_shared/src/balance_transaction_source/mod.rs index b4a59002e..f991b3683 100644 --- a/generated/stripe_shared/src/balance_transaction_source/mod.rs +++ b/generated/stripe_shared/src/balance_transaction_source/mod.rs @@ -38,26 +38,26 @@ pub enum BalanceTransactionSource { TransferReversal(stripe_shared::TransferReversal), } impl stripe_types::Object for BalanceTransactionSource { - type Id = String; - fn id(&self) -> Option<&str> { + type Id = smol_str::SmolStr; + fn id(&self) -> &Self::Id { match self { - Self::ApplicationFee(v) => Some(v.id.as_str()), - Self::Charge(v) => Some(v.id.as_str()), - Self::ConnectCollectionTransfer(v) => Some(v.id.as_str()), - Self::CustomerCashBalanceTransaction(v) => Some(v.id.as_str()), - Self::Dispute(v) => Some(v.id.as_str()), - Self::ApplicationFeeRefund(v) => Some(v.id.as_str()), - Self::IssuingAuthorization(v) => Some(v.id.as_str()), - Self::IssuingDispute(v) => Some(v.id.as_str()), - Self::IssuingTransaction(v) => Some(v.id.as_str()), - Self::Payout(v) => Some(v.id.as_str()), - Self::PlatformTaxFee(v) => Some(v.id.as_str()), - Self::Refund(v) => Some(v.id.as_str()), - Self::ReserveTransaction(v) => Some(v.id.as_str()), - Self::TaxDeductedAtSource(v) => Some(v.id.as_str()), - Self::Topup(v) => Some(v.id.as_str()), - Self::Transfer(v) => Some(v.id.as_str()), - Self::TransferReversal(v) => Some(v.id.as_str()), + Self::ApplicationFee(v) => v.id.inner(), + Self::Charge(v) => v.id.inner(), + Self::ConnectCollectionTransfer(v) => v.id.inner(), + Self::CustomerCashBalanceTransaction(v) => v.id.inner(), + Self::Dispute(v) => v.id.inner(), + Self::ApplicationFeeRefund(v) => v.id.inner(), + Self::IssuingAuthorization(v) => v.id.inner(), + Self::IssuingDispute(v) => v.id.inner(), + Self::IssuingTransaction(v) => v.id.inner(), + Self::Payout(v) => v.id.inner(), + Self::PlatformTaxFee(v) => v.id.inner(), + Self::Refund(v) => v.id.inner(), + Self::ReserveTransaction(v) => v.id.inner(), + Self::TaxDeductedAtSource(v) => v.id.inner(), + Self::Topup(v) => v.id.inner(), + Self::Transfer(v) => v.id.inner(), + Self::TransferReversal(v) => v.id.inner(), } } } diff --git a/generated/stripe_shared/src/bank_account/mod.rs b/generated/stripe_shared/src/bank_account/mod.rs index db9fe3ca9..6b4025387 100644 --- a/generated/stripe_shared/src/bank_account/mod.rs +++ b/generated/stripe_shared/src/bank_account/mod.rs @@ -137,8 +137,8 @@ impl<'de> serde::Deserialize<'de> for BankAccountAvailablePayoutMethods { } impl stripe_types::Object for BankAccount { type Id = stripe_shared::bank_account::BankAccountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(BankAccountId, "ba_" | "card_"); diff --git a/generated/stripe_shared/src/capability/mod.rs b/generated/stripe_shared/src/capability/mod.rs index 4b643f219..007c233d4 100644 --- a/generated/stripe_shared/src/capability/mod.rs +++ b/generated/stripe_shared/src/capability/mod.rs @@ -94,8 +94,8 @@ impl<'de> serde::Deserialize<'de> for CapabilityStatus { } impl stripe_types::Object for Capability { type Id = stripe_shared::capability::CapabilityId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CapabilityId); diff --git a/generated/stripe_shared/src/card/mod.rs b/generated/stripe_shared/src/card/mod.rs index 25775b8e1..4fb014cc5 100644 --- a/generated/stripe_shared/src/card/mod.rs +++ b/generated/stripe_shared/src/card/mod.rs @@ -172,8 +172,8 @@ impl<'de> serde::Deserialize<'de> for CardAvailablePayoutMethods { } impl stripe_types::Object for Card { type Id = stripe_shared::card::CardId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CardId, "card_"); diff --git a/generated/stripe_shared/src/charge/mod.rs b/generated/stripe_shared/src/charge/mod.rs index 98581355d..b6b2ba051 100644 --- a/generated/stripe_shared/src/charge/mod.rs +++ b/generated/stripe_shared/src/charge/mod.rs @@ -209,8 +209,8 @@ impl<'de> serde::Deserialize<'de> for ChargeStatus { } impl stripe_types::Object for Charge { type Id = stripe_shared::charge::ChargeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ChargeId, "ch_" | "py_"); diff --git a/generated/stripe_shared/src/checkout_session_item/mod.rs b/generated/stripe_shared/src/checkout_session_item/mod.rs index d10efe73b..155e79aad 100644 --- a/generated/stripe_shared/src/checkout_session_item/mod.rs +++ b/generated/stripe_shared/src/checkout_session_item/mod.rs @@ -37,8 +37,8 @@ pub struct CheckoutSessionItem { } impl stripe_types::Object for CheckoutSessionItem { type Id = stripe_shared::checkout_session_item::CheckoutSessionItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CheckoutSessionItemId, "li_"); diff --git a/generated/stripe_shared/src/connect_collection_transfer/mod.rs b/generated/stripe_shared/src/connect_collection_transfer/mod.rs index 707006ba1..e59259c6b 100644 --- a/generated/stripe_shared/src/connect_collection_transfer/mod.rs +++ b/generated/stripe_shared/src/connect_collection_transfer/mod.rs @@ -15,8 +15,8 @@ pub struct ConnectCollectionTransfer { } impl stripe_types::Object for ConnectCollectionTransfer { type Id = stripe_shared::connect_collection_transfer::ConnectCollectionTransferId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ConnectCollectionTransferId, "connct_"); diff --git a/generated/stripe_shared/src/coupon/mod.rs b/generated/stripe_shared/src/coupon/mod.rs index c09abf318..6b02f84e6 100644 --- a/generated/stripe_shared/src/coupon/mod.rs +++ b/generated/stripe_shared/src/coupon/mod.rs @@ -118,8 +118,8 @@ impl<'de> serde::Deserialize<'de> for CouponDuration { } impl stripe_types::Object for Coupon { type Id = stripe_shared::coupon::CouponId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CouponId); diff --git a/generated/stripe_shared/src/credit_note/mod.rs b/generated/stripe_shared/src/credit_note/mod.rs index 2da30dfcd..e0aebd71e 100644 --- a/generated/stripe_shared/src/credit_note/mod.rs +++ b/generated/stripe_shared/src/credit_note/mod.rs @@ -267,8 +267,8 @@ impl<'de> serde::Deserialize<'de> for CreditNoteType { } impl stripe_types::Object for CreditNote { type Id = stripe_shared::credit_note::CreditNoteId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CreditNoteId, "cn_"); diff --git a/generated/stripe_shared/src/credit_note_line_item/mod.rs b/generated/stripe_shared/src/credit_note_line_item/mod.rs index f09f19eca..c53b3f846 100644 --- a/generated/stripe_shared/src/credit_note_line_item/mod.rs +++ b/generated/stripe_shared/src/credit_note_line_item/mod.rs @@ -99,8 +99,8 @@ impl<'de> serde::Deserialize<'de> for CreditNoteLineItemType { } impl stripe_types::Object for CreditNoteLineItem { type Id = stripe_shared::credit_note_line_item::CreditNoteLineItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CreditNoteLineItemId, "cnli_"); diff --git a/generated/stripe_shared/src/customer/mod.rs b/generated/stripe_shared/src/customer/mod.rs index faf390578..98b1db6be 100644 --- a/generated/stripe_shared/src/customer/mod.rs +++ b/generated/stripe_shared/src/customer/mod.rs @@ -173,8 +173,8 @@ impl<'de> serde::Deserialize<'de> for CustomerTaxExempt { } impl stripe_types::Object for Customer { type Id = stripe_shared::customer::CustomerId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CustomerId, "cus_"); diff --git a/generated/stripe_shared/src/customer_balance_transaction/mod.rs b/generated/stripe_shared/src/customer_balance_transaction/mod.rs index dc481cf6b..3fb8b8702 100644 --- a/generated/stripe_shared/src/customer_balance_transaction/mod.rs +++ b/generated/stripe_shared/src/customer_balance_transaction/mod.rs @@ -135,8 +135,8 @@ impl<'de> serde::Deserialize<'de> for CustomerBalanceTransactionType { } impl stripe_types::Object for CustomerBalanceTransaction { type Id = stripe_shared::customer_balance_transaction::CustomerBalanceTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CustomerBalanceTransactionId, "cbtxn_"); diff --git a/generated/stripe_shared/src/customer_cash_balance_transaction/mod.rs b/generated/stripe_shared/src/customer_cash_balance_transaction/mod.rs index e2d495fe9..75eafa459 100644 --- a/generated/stripe_shared/src/customer_cash_balance_transaction/mod.rs +++ b/generated/stripe_shared/src/customer_cash_balance_transaction/mod.rs @@ -131,8 +131,8 @@ impl<'de> serde::Deserialize<'de> for CustomerCashBalanceTransactionType { } impl stripe_types::Object for CustomerCashBalanceTransaction { type Id = stripe_shared::customer_cash_balance_transaction::CustomerCashBalanceTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(CustomerCashBalanceTransactionId); diff --git a/generated/stripe_shared/src/deleted_account/mod.rs b/generated/stripe_shared/src/deleted_account/mod.rs index b5d117ec8..32238bc81 100644 --- a/generated/stripe_shared/src/deleted_account/mod.rs +++ b/generated/stripe_shared/src/deleted_account/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedAccount { } impl stripe_types::Object for DeletedAccount { type Id = stripe_shared::account::AccountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_bank_account/mod.rs b/generated/stripe_shared/src/deleted_bank_account/mod.rs index 936b083d8..1f854510f 100644 --- a/generated/stripe_shared/src/deleted_bank_account/mod.rs +++ b/generated/stripe_shared/src/deleted_bank_account/mod.rs @@ -10,7 +10,7 @@ pub struct DeletedBankAccount { } impl stripe_types::Object for DeletedBankAccount { type Id = stripe_shared::bank_account::BankAccountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_card/mod.rs b/generated/stripe_shared/src/deleted_card/mod.rs index 832ec1dd5..b822c7d6e 100644 --- a/generated/stripe_shared/src/deleted_card/mod.rs +++ b/generated/stripe_shared/src/deleted_card/mod.rs @@ -10,7 +10,7 @@ pub struct DeletedCard { } impl stripe_types::Object for DeletedCard { type Id = stripe_shared::card::CardId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_coupon/mod.rs b/generated/stripe_shared/src/deleted_coupon/mod.rs index cc01b88b7..720ba36d2 100644 --- a/generated/stripe_shared/src/deleted_coupon/mod.rs +++ b/generated/stripe_shared/src/deleted_coupon/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedCoupon { } impl stripe_types::Object for DeletedCoupon { type Id = stripe_shared::coupon::CouponId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_customer/mod.rs b/generated/stripe_shared/src/deleted_customer/mod.rs index 587f7e46a..b62e0d077 100644 --- a/generated/stripe_shared/src/deleted_customer/mod.rs +++ b/generated/stripe_shared/src/deleted_customer/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedCustomer { } impl stripe_types::Object for DeletedCustomer { type Id = stripe_shared::customer::CustomerId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_discount/mod.rs b/generated/stripe_shared/src/deleted_discount/mod.rs index 210ec7962..7b3759898 100644 --- a/generated/stripe_shared/src/deleted_discount/mod.rs +++ b/generated/stripe_shared/src/deleted_discount/mod.rs @@ -27,7 +27,7 @@ pub struct DeletedDiscount { } impl stripe_types::Object for DeletedDiscount { type Id = stripe_shared::discount::DiscountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_external_account/mod.rs b/generated/stripe_shared/src/deleted_external_account/mod.rs index 705b715f5..9c1039d20 100644 --- a/generated/stripe_shared/src/deleted_external_account/mod.rs +++ b/generated/stripe_shared/src/deleted_external_account/mod.rs @@ -8,11 +8,11 @@ pub enum DeletedExternalAccount { DeletedCard(stripe_shared::DeletedCard), } impl stripe_types::Object for DeletedExternalAccount { - type Id = String; - fn id(&self) -> Option<&str> { + type Id = smol_str::SmolStr; + fn id(&self) -> &Self::Id { match self { - Self::DeletedBankAccount(v) => Some(v.id.as_str()), - Self::DeletedCard(v) => Some(v.id.as_str()), + Self::DeletedBankAccount(v) => v.id.inner(), + Self::DeletedCard(v) => v.id.inner(), } } } diff --git a/generated/stripe_shared/src/deleted_invoice/mod.rs b/generated/stripe_shared/src/deleted_invoice/mod.rs index 41d610342..599fa1696 100644 --- a/generated/stripe_shared/src/deleted_invoice/mod.rs +++ b/generated/stripe_shared/src/deleted_invoice/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedInvoice { } impl stripe_types::Object for DeletedInvoice { type Id = stripe_shared::invoice::InvoiceId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_invoiceitem/mod.rs b/generated/stripe_shared/src/deleted_invoiceitem/mod.rs index 1138dd4b3..d41590048 100644 --- a/generated/stripe_shared/src/deleted_invoiceitem/mod.rs +++ b/generated/stripe_shared/src/deleted_invoiceitem/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedInvoiceitem { } impl stripe_types::Object for DeletedInvoiceitem { type Id = stripe_shared::invoice_item::InvoiceItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_payment_source/mod.rs b/generated/stripe_shared/src/deleted_payment_source/mod.rs index ade12546e..a69e8794c 100644 --- a/generated/stripe_shared/src/deleted_payment_source/mod.rs +++ b/generated/stripe_shared/src/deleted_payment_source/mod.rs @@ -8,11 +8,11 @@ pub enum DeletedPaymentSource { DeletedCard(stripe_shared::DeletedCard), } impl stripe_types::Object for DeletedPaymentSource { - type Id = String; - fn id(&self) -> Option<&str> { + type Id = smol_str::SmolStr; + fn id(&self) -> &Self::Id { match self { - Self::DeletedBankAccount(v) => Some(v.id.as_str()), - Self::DeletedCard(v) => Some(v.id.as_str()), + Self::DeletedBankAccount(v) => v.id.inner(), + Self::DeletedCard(v) => v.id.inner(), } } } diff --git a/generated/stripe_shared/src/deleted_person/mod.rs b/generated/stripe_shared/src/deleted_person/mod.rs index 38f033cee..30ea7e6cc 100644 --- a/generated/stripe_shared/src/deleted_person/mod.rs +++ b/generated/stripe_shared/src/deleted_person/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedPerson { } impl stripe_types::Object for DeletedPerson { type Id = stripe_shared::person::PersonId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_plan/mod.rs b/generated/stripe_shared/src/deleted_plan/mod.rs index f01738115..3e8ba14eb 100644 --- a/generated/stripe_shared/src/deleted_plan/mod.rs +++ b/generated/stripe_shared/src/deleted_plan/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedPlan { } impl stripe_types::Object for DeletedPlan { type Id = stripe_shared::plan::PlanId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_product/mod.rs b/generated/stripe_shared/src/deleted_product/mod.rs index 85ab54d3a..7326000cf 100644 --- a/generated/stripe_shared/src/deleted_product/mod.rs +++ b/generated/stripe_shared/src/deleted_product/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedProduct { } impl stripe_types::Object for DeletedProduct { type Id = stripe_shared::product::ProductId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_subscription_item/mod.rs b/generated/stripe_shared/src/deleted_subscription_item/mod.rs index 118e0d068..80c769083 100644 --- a/generated/stripe_shared/src/deleted_subscription_item/mod.rs +++ b/generated/stripe_shared/src/deleted_subscription_item/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedSubscriptionItem { } impl stripe_types::Object for DeletedSubscriptionItem { type Id = stripe_shared::subscription_item::SubscriptionItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_tax_id/mod.rs b/generated/stripe_shared/src/deleted_tax_id/mod.rs index a7ae6cfa0..a6b81f3ec 100644 --- a/generated/stripe_shared/src/deleted_tax_id/mod.rs +++ b/generated/stripe_shared/src/deleted_tax_id/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedTaxId { } impl stripe_types::Object for DeletedTaxId { type Id = stripe_shared::tax_id::TaxIdId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/deleted_test_helpers_test_clock/mod.rs b/generated/stripe_shared/src/deleted_test_helpers_test_clock/mod.rs index 8f6b0223d..76098053e 100644 --- a/generated/stripe_shared/src/deleted_test_helpers_test_clock/mod.rs +++ b/generated/stripe_shared/src/deleted_test_helpers_test_clock/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedTestHelpersTestClock { } impl stripe_types::Object for DeletedTestHelpersTestClock { type Id = stripe_shared::test_helpers_test_clock::TestHelpersTestClockId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_shared/src/discount/mod.rs b/generated/stripe_shared/src/discount/mod.rs index d4e23d0db..43e9f8a82 100644 --- a/generated/stripe_shared/src/discount/mod.rs +++ b/generated/stripe_shared/src/discount/mod.rs @@ -33,8 +33,8 @@ pub struct Discount { } impl stripe_types::Object for Discount { type Id = stripe_shared::discount::DiscountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(DiscountId, "di_"); diff --git a/generated/stripe_shared/src/dispute/mod.rs b/generated/stripe_shared/src/dispute/mod.rs index 7d80f3450..ee9fb7be7 100644 --- a/generated/stripe_shared/src/dispute/mod.rs +++ b/generated/stripe_shared/src/dispute/mod.rs @@ -129,8 +129,8 @@ impl<'de> serde::Deserialize<'de> for DisputeStatus { } impl stripe_types::Object for Dispute { type Id = stripe_shared::dispute::DisputeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(DisputeId, "dp_" | "du_"); diff --git a/generated/stripe_shared/src/event/mod.rs b/generated/stripe_shared/src/event/mod.rs index bf095dcaf..fb6993afe 100644 --- a/generated/stripe_shared/src/event/mod.rs +++ b/generated/stripe_shared/src/event/mod.rs @@ -786,8 +786,8 @@ impl<'de> serde::Deserialize<'de> for EventType { } impl stripe_types::Object for Event { type Id = stripe_shared::event::EventId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(EventId, "evt_"); diff --git a/generated/stripe_shared/src/external_account/mod.rs b/generated/stripe_shared/src/external_account/mod.rs index e6c50b882..3dbfdce49 100644 --- a/generated/stripe_shared/src/external_account/mod.rs +++ b/generated/stripe_shared/src/external_account/mod.rs @@ -8,11 +8,11 @@ pub enum ExternalAccount { Card(stripe_shared::Card), } impl stripe_types::Object for ExternalAccount { - type Id = String; - fn id(&self) -> Option<&str> { + type Id = smol_str::SmolStr; + fn id(&self) -> &Self::Id { match self { - Self::BankAccount(v) => Some(v.id.as_str()), - Self::Card(v) => Some(v.id.as_str()), + Self::BankAccount(v) => v.id.inner(), + Self::Card(v) => v.id.inner(), } } } diff --git a/generated/stripe_shared/src/file/mod.rs b/generated/stripe_shared/src/file/mod.rs index 9d6e25298..7070975ed 100644 --- a/generated/stripe_shared/src/file/mod.rs +++ b/generated/stripe_shared/src/file/mod.rs @@ -132,8 +132,8 @@ impl<'de> serde::Deserialize<'de> for FilePurpose { } impl stripe_types::Object for File { type Id = stripe_shared::file::FileId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(FileId, "file_"); diff --git a/generated/stripe_shared/src/file_link/mod.rs b/generated/stripe_shared/src/file_link/mod.rs index dd941baf8..0da544d46 100644 --- a/generated/stripe_shared/src/file_link/mod.rs +++ b/generated/stripe_shared/src/file_link/mod.rs @@ -27,8 +27,8 @@ pub struct FileLink { } impl stripe_types::Object for FileLink { type Id = stripe_shared::file_link::FileLinkId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(FileLinkId, "link_"); diff --git a/generated/stripe_shared/src/invoice/mod.rs b/generated/stripe_shared/src/invoice/mod.rs index b758212ab..8419a576c 100644 --- a/generated/stripe_shared/src/invoice/mod.rs +++ b/generated/stripe_shared/src/invoice/mod.rs @@ -579,8 +579,8 @@ impl<'de> serde::Deserialize<'de> for InvoiceStatus { } impl stripe_types::Object for Invoice { type Id = Option; - fn id(&self) -> Option<&str> { - self.id.as_deref() + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(InvoiceId, "in_"); diff --git a/generated/stripe_shared/src/invoice_item/mod.rs b/generated/stripe_shared/src/invoice_item/mod.rs index 4319ef78e..321b09a2c 100644 --- a/generated/stripe_shared/src/invoice_item/mod.rs +++ b/generated/stripe_shared/src/invoice_item/mod.rs @@ -72,8 +72,8 @@ pub struct InvoiceItem { } impl stripe_types::Object for InvoiceItem { type Id = stripe_shared::invoice_item::InvoiceItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(InvoiceItemId, "ii_"); diff --git a/generated/stripe_shared/src/invoice_line_item/mod.rs b/generated/stripe_shared/src/invoice_line_item/mod.rs index e5b76662d..8288aae4c 100644 --- a/generated/stripe_shared/src/invoice_line_item/mod.rs +++ b/generated/stripe_shared/src/invoice_line_item/mod.rs @@ -126,8 +126,8 @@ impl<'de> serde::Deserialize<'de> for InvoiceLineItemType { } impl stripe_types::Object for InvoiceLineItem { type Id = stripe_shared::invoice_line_item::InvoiceLineItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(InvoiceLineItemId); diff --git a/generated/stripe_shared/src/issuing_authorization/mod.rs b/generated/stripe_shared/src/issuing_authorization/mod.rs index 319466ee7..e6fa13716 100644 --- a/generated/stripe_shared/src/issuing_authorization/mod.rs +++ b/generated/stripe_shared/src/issuing_authorization/mod.rs @@ -216,8 +216,8 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationStatus { } impl stripe_types::Object for IssuingAuthorization { type Id = stripe_shared::issuing_authorization::IssuingAuthorizationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IssuingAuthorizationId, "iauth_"); diff --git a/generated/stripe_shared/src/issuing_card/mod.rs b/generated/stripe_shared/src/issuing_card/mod.rs index 6fcdf547d..5b4975458 100644 --- a/generated/stripe_shared/src/issuing_card/mod.rs +++ b/generated/stripe_shared/src/issuing_card/mod.rs @@ -317,8 +317,8 @@ impl<'de> serde::Deserialize<'de> for IssuingCardType { } impl stripe_types::Object for IssuingCard { type Id = stripe_shared::issuing_card::IssuingCardId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IssuingCardId, "ic_"); diff --git a/generated/stripe_shared/src/issuing_cardholder/mod.rs b/generated/stripe_shared/src/issuing_cardholder/mod.rs index b37cb6552..a3ae2329f 100644 --- a/generated/stripe_shared/src/issuing_cardholder/mod.rs +++ b/generated/stripe_shared/src/issuing_cardholder/mod.rs @@ -244,8 +244,8 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderType { } impl stripe_types::Object for IssuingCardholder { type Id = stripe_shared::issuing_cardholder::IssuingCardholderId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IssuingCardholderId, "ich_"); diff --git a/generated/stripe_shared/src/issuing_dispute/mod.rs b/generated/stripe_shared/src/issuing_dispute/mod.rs index 8285a5f9c..9b071db9c 100644 --- a/generated/stripe_shared/src/issuing_dispute/mod.rs +++ b/generated/stripe_shared/src/issuing_dispute/mod.rs @@ -102,8 +102,8 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeStatus { } impl stripe_types::Object for IssuingDispute { type Id = stripe_shared::issuing_dispute::IssuingDisputeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IssuingDisputeId, "idp_"); diff --git a/generated/stripe_shared/src/issuing_token/mod.rs b/generated/stripe_shared/src/issuing_token/mod.rs index b3c84ab33..f3ed77505 100644 --- a/generated/stripe_shared/src/issuing_token/mod.rs +++ b/generated/stripe_shared/src/issuing_token/mod.rs @@ -220,8 +220,8 @@ impl<'de> serde::Deserialize<'de> for IssuingTokenWalletProvider { } impl stripe_types::Object for IssuingToken { type Id = stripe_shared::issuing_token::IssuingTokenId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IssuingTokenId); diff --git a/generated/stripe_shared/src/issuing_transaction/mod.rs b/generated/stripe_shared/src/issuing_transaction/mod.rs index 4ca632750..a583cadd0 100644 --- a/generated/stripe_shared/src/issuing_transaction/mod.rs +++ b/generated/stripe_shared/src/issuing_transaction/mod.rs @@ -191,8 +191,8 @@ impl<'de> serde::Deserialize<'de> for IssuingTransactionWallet { } impl stripe_types::Object for IssuingTransaction { type Id = stripe_shared::issuing_transaction::IssuingTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(IssuingTransactionId, "ipi_"); diff --git a/generated/stripe_shared/src/mandate/mod.rs b/generated/stripe_shared/src/mandate/mod.rs index 05a7650cd..b72377971 100644 --- a/generated/stripe_shared/src/mandate/mod.rs +++ b/generated/stripe_shared/src/mandate/mod.rs @@ -143,8 +143,8 @@ impl<'de> serde::Deserialize<'de> for MandateType { } impl stripe_types::Object for Mandate { type Id = stripe_shared::mandate::MandateId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(MandateId, "mandate_"); diff --git a/generated/stripe_shared/src/payment_intent/mod.rs b/generated/stripe_shared/src/payment_intent/mod.rs index 10f26c495..d5e1730ff 100644 --- a/generated/stripe_shared/src/payment_intent/mod.rs +++ b/generated/stripe_shared/src/payment_intent/mod.rs @@ -475,8 +475,8 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentStatus { } impl stripe_types::Object for PaymentIntent { type Id = stripe_shared::payment_intent::PaymentIntentId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PaymentIntentId, "pi_"); diff --git a/generated/stripe_shared/src/payment_link/mod.rs b/generated/stripe_shared/src/payment_link/mod.rs index 9bb403a3f..5baff54ab 100644 --- a/generated/stripe_shared/src/payment_link/mod.rs +++ b/generated/stripe_shared/src/payment_link/mod.rs @@ -464,8 +464,8 @@ impl<'de> serde::Deserialize<'de> for PaymentLinkSubmitType { } impl stripe_types::Object for PaymentLink { type Id = stripe_shared::payment_link::PaymentLinkId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PaymentLinkId, "plink_"); diff --git a/generated/stripe_shared/src/payment_method/mod.rs b/generated/stripe_shared/src/payment_method/mod.rs index eaa8e6e85..c0ea1508a 100644 --- a/generated/stripe_shared/src/payment_method/mod.rs +++ b/generated/stripe_shared/src/payment_method/mod.rs @@ -262,8 +262,8 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodType { } impl stripe_types::Object for PaymentMethod { type Id = stripe_shared::payment_method::PaymentMethodId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PaymentMethodId, "pm_" | "card_" | "src_" | "ba_"); diff --git a/generated/stripe_shared/src/payment_source/mod.rs b/generated/stripe_shared/src/payment_source/mod.rs index 890cafb18..08c942c45 100644 --- a/generated/stripe_shared/src/payment_source/mod.rs +++ b/generated/stripe_shared/src/payment_source/mod.rs @@ -12,13 +12,13 @@ pub enum PaymentSource { Source(stripe_shared::Source), } impl stripe_types::Object for PaymentSource { - type Id = String; - fn id(&self) -> Option<&str> { + type Id = smol_str::SmolStr; + fn id(&self) -> &Self::Id { match self { - Self::Account(v) => Some(v.id.as_str()), - Self::BankAccount(v) => Some(v.id.as_str()), - Self::Card(v) => Some(v.id.as_str()), - Self::Source(v) => Some(v.id.as_str()), + Self::Account(v) => v.id.inner(), + Self::BankAccount(v) => v.id.inner(), + Self::Card(v) => v.id.inner(), + Self::Source(v) => v.id.inner(), } } } diff --git a/generated/stripe_shared/src/payout/mod.rs b/generated/stripe_shared/src/payout/mod.rs index 2b4fcffce..b5af70005 100644 --- a/generated/stripe_shared/src/payout/mod.rs +++ b/generated/stripe_shared/src/payout/mod.rs @@ -194,8 +194,8 @@ impl<'de> serde::Deserialize<'de> for PayoutType { } impl stripe_types::Object for Payout { type Id = stripe_shared::payout::PayoutId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PayoutId, "po_"); diff --git a/generated/stripe_shared/src/person/mod.rs b/generated/stripe_shared/src/person/mod.rs index 2f7dff66a..ba83bca11 100644 --- a/generated/stripe_shared/src/person/mod.rs +++ b/generated/stripe_shared/src/person/mod.rs @@ -159,8 +159,8 @@ impl<'de> serde::Deserialize<'de> for PersonPoliticalExposure { } impl stripe_types::Object for Person { type Id = stripe_shared::person::PersonId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PersonId, "person_"); diff --git a/generated/stripe_shared/src/plan/mod.rs b/generated/stripe_shared/src/plan/mod.rs index dbe85568c..d2890e5e6 100644 --- a/generated/stripe_shared/src/plan/mod.rs +++ b/generated/stripe_shared/src/plan/mod.rs @@ -402,8 +402,8 @@ impl<'de> serde::Deserialize<'de> for PlanUsageType { } impl stripe_types::Object for Plan { type Id = stripe_shared::plan::PlanId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PlanId); diff --git a/generated/stripe_shared/src/platform_tax_fee/mod.rs b/generated/stripe_shared/src/platform_tax_fee/mod.rs index 1e1f4b15e..ad6c47a57 100644 --- a/generated/stripe_shared/src/platform_tax_fee/mod.rs +++ b/generated/stripe_shared/src/platform_tax_fee/mod.rs @@ -12,8 +12,8 @@ pub struct PlatformTaxFee { } impl stripe_types::Object for PlatformTaxFee { type Id = stripe_shared::platform_tax_fee::PlatformTaxFeeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PlatformTaxFeeId, "ptf_"); diff --git a/generated/stripe_shared/src/price/mod.rs b/generated/stripe_shared/src/price/mod.rs index 6ada9e182..7767f207b 100644 --- a/generated/stripe_shared/src/price/mod.rs +++ b/generated/stripe_shared/src/price/mod.rs @@ -330,8 +330,8 @@ impl<'de> serde::Deserialize<'de> for PriceType { } impl stripe_types::Object for Price { type Id = stripe_shared::price::PriceId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PriceId, "price_"); diff --git a/generated/stripe_shared/src/product/mod.rs b/generated/stripe_shared/src/product/mod.rs index 5628de1d2..beb7a4527 100644 --- a/generated/stripe_shared/src/product/mod.rs +++ b/generated/stripe_shared/src/product/mod.rs @@ -127,8 +127,8 @@ impl<'de> serde::Deserialize<'de> for ProductType { } impl stripe_types::Object for Product { type Id = stripe_shared::product::ProductId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ProductId); diff --git a/generated/stripe_shared/src/promotion_code/mod.rs b/generated/stripe_shared/src/promotion_code/mod.rs index fbea2b2e5..42c461e7e 100644 --- a/generated/stripe_shared/src/promotion_code/mod.rs +++ b/generated/stripe_shared/src/promotion_code/mod.rs @@ -36,8 +36,8 @@ pub struct PromotionCode { } impl stripe_types::Object for PromotionCode { type Id = stripe_shared::promotion_code::PromotionCodeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(PromotionCodeId, "promo_"); diff --git a/generated/stripe_shared/src/quote/mod.rs b/generated/stripe_shared/src/quote/mod.rs index a1638ee27..b4f2559c9 100644 --- a/generated/stripe_shared/src/quote/mod.rs +++ b/generated/stripe_shared/src/quote/mod.rs @@ -224,8 +224,8 @@ impl<'de> serde::Deserialize<'de> for QuoteStatus { } impl stripe_types::Object for Quote { type Id = stripe_shared::quote::QuoteId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(QuoteId, "qt_"); diff --git a/generated/stripe_shared/src/refund/mod.rs b/generated/stripe_shared/src/refund/mod.rs index 7beb9c7bb..5c2914ed8 100644 --- a/generated/stripe_shared/src/refund/mod.rs +++ b/generated/stripe_shared/src/refund/mod.rs @@ -130,8 +130,8 @@ impl<'de> serde::Deserialize<'de> for RefundReason { } impl stripe_types::Object for Refund { type Id = stripe_shared::refund::RefundId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(RefundId, "re_" | "pyr_"); diff --git a/generated/stripe_shared/src/reserve_transaction/mod.rs b/generated/stripe_shared/src/reserve_transaction/mod.rs index bf10ae01f..8e44f189f 100644 --- a/generated/stripe_shared/src/reserve_transaction/mod.rs +++ b/generated/stripe_shared/src/reserve_transaction/mod.rs @@ -14,8 +14,8 @@ pub struct ReserveTransaction { } impl stripe_types::Object for ReserveTransaction { type Id = stripe_shared::reserve_transaction::ReserveTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ReserveTransactionId, "rtx_"); diff --git a/generated/stripe_shared/src/review/mod.rs b/generated/stripe_shared/src/review/mod.rs index 18d741473..76c383242 100644 --- a/generated/stripe_shared/src/review/mod.rs +++ b/generated/stripe_shared/src/review/mod.rs @@ -175,8 +175,8 @@ impl<'de> serde::Deserialize<'de> for ReviewOpenedReason { } impl stripe_types::Object for Review { type Id = stripe_shared::review::ReviewId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ReviewId, "prv_"); diff --git a/generated/stripe_shared/src/rule/mod.rs b/generated/stripe_shared/src/rule/mod.rs index e261659c9..7246e062f 100644 --- a/generated/stripe_shared/src/rule/mod.rs +++ b/generated/stripe_shared/src/rule/mod.rs @@ -9,8 +9,8 @@ pub struct Rule { } impl stripe_types::Object for Rule { type Id = stripe_shared::rule::RuleId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(RuleId); diff --git a/generated/stripe_shared/src/setup_attempt/mod.rs b/generated/stripe_shared/src/setup_attempt/mod.rs index b699634fb..f904a3d7f 100644 --- a/generated/stripe_shared/src/setup_attempt/mod.rs +++ b/generated/stripe_shared/src/setup_attempt/mod.rs @@ -110,8 +110,8 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptFlowDirections { } impl stripe_types::Object for SetupAttempt { type Id = stripe_shared::setup_attempt::SetupAttemptId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(SetupAttemptId, "setatt_"); diff --git a/generated/stripe_shared/src/setup_intent/mod.rs b/generated/stripe_shared/src/setup_intent/mod.rs index e6ffd51b1..b7ff8b91b 100644 --- a/generated/stripe_shared/src/setup_intent/mod.rs +++ b/generated/stripe_shared/src/setup_intent/mod.rs @@ -303,8 +303,8 @@ impl<'de> serde::Deserialize<'de> for SetupIntentStatus { } impl stripe_types::Object for SetupIntent { type Id = stripe_shared::setup_intent::SetupIntentId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(SetupIntentId, "seti_"); diff --git a/generated/stripe_shared/src/shipping_rate/mod.rs b/generated/stripe_shared/src/shipping_rate/mod.rs index f0d818d9a..5e3932efe 100644 --- a/generated/stripe_shared/src/shipping_rate/mod.rs +++ b/generated/stripe_shared/src/shipping_rate/mod.rs @@ -168,8 +168,8 @@ impl<'de> serde::Deserialize<'de> for ShippingRateType { } impl stripe_types::Object for ShippingRate { type Id = stripe_shared::shipping_rate::ShippingRateId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(ShippingRateId, "shr_"); diff --git a/generated/stripe_shared/src/source/mod.rs b/generated/stripe_shared/src/source/mod.rs index 2aed72f71..2b63de21f 100644 --- a/generated/stripe_shared/src/source/mod.rs +++ b/generated/stripe_shared/src/source/mod.rs @@ -227,8 +227,8 @@ impl<'de> serde::Deserialize<'de> for SourceType { } impl stripe_types::Object for Source { type Id = stripe_shared::source::SourceId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(SourceId, "src_"); diff --git a/generated/stripe_shared/src/source_transaction/mod.rs b/generated/stripe_shared/src/source_transaction/mod.rs index 6fac061b8..7242bb187 100644 --- a/generated/stripe_shared/src/source_transaction/mod.rs +++ b/generated/stripe_shared/src/source_transaction/mod.rs @@ -143,8 +143,8 @@ impl<'de> serde::Deserialize<'de> for SourceTransactionType { } impl stripe_types::Object for SourceTransaction { type Id = stripe_shared::source_transaction::SourceTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(SourceTransactionId); diff --git a/generated/stripe_shared/src/subscription/mod.rs b/generated/stripe_shared/src/subscription/mod.rs index 7cc59467e..dce1cbca1 100644 --- a/generated/stripe_shared/src/subscription/mod.rs +++ b/generated/stripe_shared/src/subscription/mod.rs @@ -297,8 +297,8 @@ impl<'de> serde::Deserialize<'de> for SubscriptionStatus { } impl stripe_types::Object for Subscription { type Id = stripe_shared::subscription::SubscriptionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(SubscriptionId, "sub_"); diff --git a/generated/stripe_shared/src/subscription_item/mod.rs b/generated/stripe_shared/src/subscription_item/mod.rs index f6a003823..a4b78dd2e 100644 --- a/generated/stripe_shared/src/subscription_item/mod.rs +++ b/generated/stripe_shared/src/subscription_item/mod.rs @@ -28,8 +28,8 @@ pub struct SubscriptionItem { } impl stripe_types::Object for SubscriptionItem { type Id = stripe_shared::subscription_item::SubscriptionItemId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(SubscriptionItemId, "si_"); diff --git a/generated/stripe_shared/src/subscription_schedule/mod.rs b/generated/stripe_shared/src/subscription_schedule/mod.rs index 2050e7bcd..a52ad00c6 100644 --- a/generated/stripe_shared/src/subscription_schedule/mod.rs +++ b/generated/stripe_shared/src/subscription_schedule/mod.rs @@ -195,8 +195,8 @@ impl<'de> serde::Deserialize<'de> for SubscriptionScheduleStatus { } impl stripe_types::Object for SubscriptionSchedule { type Id = stripe_shared::subscription_schedule::SubscriptionScheduleId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(SubscriptionScheduleId, "sub_sched_"); diff --git a/generated/stripe_shared/src/tax_code/mod.rs b/generated/stripe_shared/src/tax_code/mod.rs index c0428f555..e6c6017e0 100644 --- a/generated/stripe_shared/src/tax_code/mod.rs +++ b/generated/stripe_shared/src/tax_code/mod.rs @@ -10,8 +10,8 @@ pub struct TaxCode { } impl stripe_types::Object for TaxCode { type Id = stripe_shared::tax_code::TaxCodeId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxCodeId, "txcd_"); diff --git a/generated/stripe_shared/src/tax_deducted_at_source/mod.rs b/generated/stripe_shared/src/tax_deducted_at_source/mod.rs index 4536c3c4d..27267e74f 100644 --- a/generated/stripe_shared/src/tax_deducted_at_source/mod.rs +++ b/generated/stripe_shared/src/tax_deducted_at_source/mod.rs @@ -15,8 +15,8 @@ pub struct TaxDeductedAtSource { } impl stripe_types::Object for TaxDeductedAtSource { type Id = stripe_shared::tax_deducted_at_source::TaxDeductedAtSourceId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxDeductedAtSourceId, "itds_"); diff --git a/generated/stripe_shared/src/tax_id/mod.rs b/generated/stripe_shared/src/tax_id/mod.rs index 1d4d1ce8d..d97cc45b6 100644 --- a/generated/stripe_shared/src/tax_id/mod.rs +++ b/generated/stripe_shared/src/tax_id/mod.rs @@ -283,8 +283,8 @@ impl<'de> serde::Deserialize<'de> for TaxIdType { } impl stripe_types::Object for TaxId { type Id = stripe_shared::tax_id::TaxIdId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxIdId, "txi_" | "atxi_"); diff --git a/generated/stripe_shared/src/tax_rate/mod.rs b/generated/stripe_shared/src/tax_rate/mod.rs index ed5d83824..b5fce6382 100644 --- a/generated/stripe_shared/src/tax_rate/mod.rs +++ b/generated/stripe_shared/src/tax_rate/mod.rs @@ -146,8 +146,8 @@ impl<'de> serde::Deserialize<'de> for TaxRateTaxType { } impl stripe_types::Object for TaxRate { type Id = stripe_shared::tax_rate::TaxRateId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TaxRateId, "txr_"); diff --git a/generated/stripe_shared/src/test_helpers_test_clock/mod.rs b/generated/stripe_shared/src/test_helpers_test_clock/mod.rs index 9d0cd3339..d2e3bc804 100644 --- a/generated/stripe_shared/src/test_helpers_test_clock/mod.rs +++ b/generated/stripe_shared/src/test_helpers_test_clock/mod.rs @@ -85,8 +85,8 @@ impl<'de> serde::Deserialize<'de> for TestHelpersTestClockStatus { } impl stripe_types::Object for TestHelpersTestClock { type Id = stripe_shared::test_helpers_test_clock::TestHelpersTestClockId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TestHelpersTestClockId, "clock_"); diff --git a/generated/stripe_shared/src/topup/mod.rs b/generated/stripe_shared/src/topup/mod.rs index a89be0cbc..5a34f092a 100644 --- a/generated/stripe_shared/src/topup/mod.rs +++ b/generated/stripe_shared/src/topup/mod.rs @@ -122,8 +122,8 @@ impl<'de> serde::Deserialize<'de> for TopupStatus { } impl stripe_types::Object for Topup { type Id = stripe_shared::topup::TopupId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TopupId, "tu_"); diff --git a/generated/stripe_shared/src/transfer/mod.rs b/generated/stripe_shared/src/transfer/mod.rs index c432bc68f..4721c7e9a 100644 --- a/generated/stripe_shared/src/transfer/mod.rs +++ b/generated/stripe_shared/src/transfer/mod.rs @@ -59,8 +59,8 @@ pub struct Transfer { } impl stripe_types::Object for Transfer { type Id = stripe_shared::transfer::TransferId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TransferId, "tr_"); diff --git a/generated/stripe_shared/src/transfer_reversal/mod.rs b/generated/stripe_shared/src/transfer_reversal/mod.rs index 36c8290d0..0b0c5c3f1 100644 --- a/generated/stripe_shared/src/transfer_reversal/mod.rs +++ b/generated/stripe_shared/src/transfer_reversal/mod.rs @@ -33,8 +33,8 @@ pub struct TransferReversal { } impl stripe_types::Object for TransferReversal { type Id = stripe_shared::transfer_reversal::TransferReversalId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TransferReversalId, "trr_"); diff --git a/generated/stripe_shared/src/usage_record_summary/mod.rs b/generated/stripe_shared/src/usage_record_summary/mod.rs index 2f1e9c918..a85c801bc 100644 --- a/generated/stripe_shared/src/usage_record_summary/mod.rs +++ b/generated/stripe_shared/src/usage_record_summary/mod.rs @@ -14,8 +14,8 @@ pub struct UsageRecordSummary { } impl stripe_types::Object for UsageRecordSummary { type Id = stripe_shared::usage_record_summary::UsageRecordSummaryId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(UsageRecordSummaryId, "urs_" | "sis_"); diff --git a/generated/stripe_terminal/src/deleted_terminal_configuration/mod.rs b/generated/stripe_terminal/src/deleted_terminal_configuration/mod.rs index ac0e32360..f3d17b225 100644 --- a/generated/stripe_terminal/src/deleted_terminal_configuration/mod.rs +++ b/generated/stripe_terminal/src/deleted_terminal_configuration/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedTerminalConfiguration { } impl stripe_types::Object for DeletedTerminalConfiguration { type Id = stripe_terminal::terminal_configuration::TerminalConfigurationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_terminal/src/deleted_terminal_location/mod.rs b/generated/stripe_terminal/src/deleted_terminal_location/mod.rs index 2f52913bb..64955a93a 100644 --- a/generated/stripe_terminal/src/deleted_terminal_location/mod.rs +++ b/generated/stripe_terminal/src/deleted_terminal_location/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedTerminalLocation { } impl stripe_types::Object for DeletedTerminalLocation { type Id = stripe_terminal::terminal_location::TerminalLocationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_terminal/src/deleted_terminal_reader/mod.rs b/generated/stripe_terminal/src/deleted_terminal_reader/mod.rs index 25a3d97ce..87b92b059 100644 --- a/generated/stripe_terminal/src/deleted_terminal_reader/mod.rs +++ b/generated/stripe_terminal/src/deleted_terminal_reader/mod.rs @@ -7,7 +7,7 @@ pub struct DeletedTerminalReader { } impl stripe_types::Object for DeletedTerminalReader { type Id = stripe_terminal::terminal_reader::TerminalReaderId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } diff --git a/generated/stripe_terminal/src/terminal_configuration/mod.rs b/generated/stripe_terminal/src/terminal_configuration/mod.rs index 9a38d9d51..cbf66c7c9 100644 --- a/generated/stripe_terminal/src/terminal_configuration/mod.rs +++ b/generated/stripe_terminal/src/terminal_configuration/mod.rs @@ -20,8 +20,8 @@ pub struct TerminalConfiguration { } impl stripe_types::Object for TerminalConfiguration { type Id = stripe_terminal::terminal_configuration::TerminalConfigurationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TerminalConfigurationId, "tmc_"); diff --git a/generated/stripe_terminal/src/terminal_location/mod.rs b/generated/stripe_terminal/src/terminal_location/mod.rs index 1d618561a..8d129028e 100644 --- a/generated/stripe_terminal/src/terminal_location/mod.rs +++ b/generated/stripe_terminal/src/terminal_location/mod.rs @@ -20,8 +20,8 @@ pub struct TerminalLocation { } impl stripe_types::Object for TerminalLocation { type Id = stripe_terminal::terminal_location::TerminalLocationId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TerminalLocationId, "tml_"); diff --git a/generated/stripe_terminal/src/terminal_reader/mod.rs b/generated/stripe_terminal/src/terminal_reader/mod.rs index 588d03b43..bc5d416c2 100644 --- a/generated/stripe_terminal/src/terminal_reader/mod.rs +++ b/generated/stripe_terminal/src/terminal_reader/mod.rs @@ -101,8 +101,8 @@ impl<'de> serde::Deserialize<'de> for TerminalReaderDeviceType { } impl stripe_types::Object for TerminalReader { type Id = stripe_terminal::terminal_reader::TerminalReaderId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TerminalReaderId, "tmr_"); diff --git a/generated/stripe_treasury/src/treasury_credit_reversal/mod.rs b/generated/stripe_treasury/src/treasury_credit_reversal/mod.rs index 9c50a5641..0fe38eb63 100644 --- a/generated/stripe_treasury/src/treasury_credit_reversal/mod.rs +++ b/generated/stripe_treasury/src/treasury_credit_reversal/mod.rs @@ -159,8 +159,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryCreditReversalStatus { } impl stripe_types::Object for TreasuryCreditReversal { type Id = stripe_treasury::treasury_credit_reversal::TreasuryCreditReversalId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryCreditReversalId); diff --git a/generated/stripe_treasury/src/treasury_debit_reversal/mod.rs b/generated/stripe_treasury/src/treasury_debit_reversal/mod.rs index 518e81e94..dfe073528 100644 --- a/generated/stripe_treasury/src/treasury_debit_reversal/mod.rs +++ b/generated/stripe_treasury/src/treasury_debit_reversal/mod.rs @@ -161,8 +161,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryDebitReversalStatus { } impl stripe_types::Object for TreasuryDebitReversal { type Id = stripe_treasury::treasury_debit_reversal::TreasuryDebitReversalId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryDebitReversalId); diff --git a/generated/stripe_treasury/src/treasury_financial_account/mod.rs b/generated/stripe_treasury/src/treasury_financial_account/mod.rs index 659d07e4f..95f8d0cbe 100644 --- a/generated/stripe_treasury/src/treasury_financial_account/mod.rs +++ b/generated/stripe_treasury/src/treasury_financial_account/mod.rs @@ -357,8 +357,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountStatus { } impl stripe_types::Object for TreasuryFinancialAccount { type Id = stripe_treasury::treasury_financial_account::TreasuryFinancialAccountId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryFinancialAccountId); diff --git a/generated/stripe_treasury/src/treasury_inbound_transfer/mod.rs b/generated/stripe_treasury/src/treasury_inbound_transfer/mod.rs index 11fd653b3..a65c809a5 100644 --- a/generated/stripe_treasury/src/treasury_inbound_transfer/mod.rs +++ b/generated/stripe_treasury/src/treasury_inbound_transfer/mod.rs @@ -130,8 +130,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryInboundTransferStatus { } impl stripe_types::Object for TreasuryInboundTransfer { type Id = stripe_treasury::treasury_inbound_transfer::TreasuryInboundTransferId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryInboundTransferId); diff --git a/generated/stripe_treasury/src/treasury_outbound_payment/mod.rs b/generated/stripe_treasury/src/treasury_outbound_payment/mod.rs index 510fad28a..a6bfa05cd 100644 --- a/generated/stripe_treasury/src/treasury_outbound_payment/mod.rs +++ b/generated/stripe_treasury/src/treasury_outbound_payment/mod.rs @@ -139,8 +139,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryOutboundPaymentStatus { } impl stripe_types::Object for TreasuryOutboundPayment { type Id = stripe_treasury::treasury_outbound_payment::TreasuryOutboundPaymentId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryOutboundPaymentId); diff --git a/generated/stripe_treasury/src/treasury_outbound_transfer/mod.rs b/generated/stripe_treasury/src/treasury_outbound_transfer/mod.rs index f4c912653..b459afb82 100644 --- a/generated/stripe_treasury/src/treasury_outbound_transfer/mod.rs +++ b/generated/stripe_treasury/src/treasury_outbound_transfer/mod.rs @@ -129,8 +129,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryOutboundTransferStatus { } impl stripe_types::Object for TreasuryOutboundTransfer { type Id = stripe_treasury::treasury_outbound_transfer::TreasuryOutboundTransferId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryOutboundTransferId); diff --git a/generated/stripe_treasury/src/treasury_received_credit/mod.rs b/generated/stripe_treasury/src/treasury_received_credit/mod.rs index 4772d360e..9fa421322 100644 --- a/generated/stripe_treasury/src/treasury_received_credit/mod.rs +++ b/generated/stripe_treasury/src/treasury_received_credit/mod.rs @@ -239,8 +239,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditStatus { } impl stripe_types::Object for TreasuryReceivedCredit { type Id = stripe_treasury::treasury_received_credit::TreasuryReceivedCreditId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryReceivedCreditId); diff --git a/generated/stripe_treasury/src/treasury_received_debit/mod.rs b/generated/stripe_treasury/src/treasury_received_debit/mod.rs index 83954e24c..8c3d58cf5 100644 --- a/generated/stripe_treasury/src/treasury_received_debit/mod.rs +++ b/generated/stripe_treasury/src/treasury_received_debit/mod.rs @@ -239,8 +239,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitStatus { } impl stripe_types::Object for TreasuryReceivedDebit { type Id = stripe_treasury::treasury_received_debit::TreasuryReceivedDebitId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryReceivedDebitId); diff --git a/generated/stripe_treasury/src/treasury_transaction/mod.rs b/generated/stripe_treasury/src/treasury_transaction/mod.rs index 6747131b1..712a548ac 100644 --- a/generated/stripe_treasury/src/treasury_transaction/mod.rs +++ b/generated/stripe_treasury/src/treasury_transaction/mod.rs @@ -181,8 +181,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionStatus { } impl stripe_types::Object for TreasuryTransaction { type Id = stripe_treasury::treasury_transaction::TreasuryTransactionId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryTransactionId); diff --git a/generated/stripe_treasury/src/treasury_transaction_entry/mod.rs b/generated/stripe_treasury/src/treasury_transaction_entry/mod.rs index 6e8ffe9ad..3990d7286 100644 --- a/generated/stripe_treasury/src/treasury_transaction_entry/mod.rs +++ b/generated/stripe_treasury/src/treasury_transaction_entry/mod.rs @@ -229,8 +229,8 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionEntryType { } impl stripe_types::Object for TreasuryTransactionEntry { type Id = stripe_treasury::treasury_transaction_entry::TreasuryTransactionEntryId; - fn id(&self) -> Option<&str> { - Some(self.id.as_str()) + fn id(&self) -> &Self::Id { + &self.id } } stripe_types::def_id!(TreasuryTransactionEntryId); diff --git a/openapi/src/object_writing.rs b/openapi/src/object_writing.rs index 4ebd5e43a..cf48db0ca 100644 --- a/openapi/src/object_writing.rs +++ b/openapi/src/object_writing.rs @@ -116,14 +116,12 @@ pub fn gen_obj( if let Some(id_typ) = comp.id_type() { let id_type = components.construct_printable_type(id_typ); match &obj { - RustObject::Struct(_) => { - write_object_trait(&mut out, ident, &id_type, id_typ.is_option()) - } + RustObject::Struct(_) => write_object_trait(&mut out, ident, &id_type), RustObject::Enum(variants) => { let Some(object_names) = as_enum_of_objects(components, variants) else { panic!("Object {} is an enum that is not a union of stripe objects", ident); }; - write_object_trait_for_enum(components, &mut out, ident, &id_type, &object_names) + write_object_trait_for_enum(components, &mut out, ident, &object_names) } RustObject::FieldlessEnum(_) => { panic!("Did not expect enum to have an id"); diff --git a/openapi/src/templates/object_trait.rs b/openapi/src/templates/object_trait.rs index 4fbd8c614..e13dd3510 100644 --- a/openapi/src/templates/object_trait.rs +++ b/openapi/src/templates/object_trait.rs @@ -9,20 +9,14 @@ use crate::rust_object::ObjectRef; use crate::types::RustIdent; use crate::STRIPE_TYPES; -pub fn write_object_trait( - out: &mut String, - ident: &RustIdent, - id_type: &PrintableType, - is_optional: bool, -) { - let body = if is_optional { "self.id.as_deref()" } else { "Some(self.id.as_str())" }; +pub fn write_object_trait(out: &mut String, ident: &RustIdent, id_type: &PrintableType) { let _ = writedoc!( out, r#" impl {STRIPE_TYPES}::Object for {ident} {{ type Id = {id_type}; - fn id(&self) -> Option<&str> {{ - {body} + fn id(&self) -> &Self::Id {{ + &self.id }} }} "# @@ -33,21 +27,20 @@ pub fn write_object_trait_for_enum( components: &Components, out: &mut String, ident: &RustIdent, - id_type: &PrintableType, variants: &IndexMap<&str, ObjectRef>, ) { let mut match_inner = String::with_capacity(32); for obj in variants.values() { let comp = components.get(&obj.path); let ident = comp.ident(); - let _ = writeln!(match_inner, "Self::{ident}(v) => Some(v.id.as_str()),"); + let _ = writeln!(match_inner, "Self::{ident}(v) => v.id.inner(),"); } let _ = writedoc!( out, r#" impl {STRIPE_TYPES}::Object for {ident} {{ - type Id = {id_type}; - fn id(&self) -> Option<&str> {{ + type Id = smol_str::SmolStr; + fn id(&self) -> &Self::Id {{ match self {{ {match_inner} }} diff --git a/stripe_types/src/expandable.rs b/stripe_types/src/expandable.rs index 282f769f9..2d942c107 100644 --- a/stripe_types/src/expandable.rs +++ b/stripe_types/src/expandable.rs @@ -40,6 +40,13 @@ impl Expandable { } } + pub fn id(&self) -> &T::Id { + match self { + Expandable::Id(id) => id, + Expandable::Object(obj) => obj.id(), + } + } + pub fn into_object(self) -> Option { match self { Expandable::Id(_) => None, diff --git a/stripe_types/src/ids.rs b/stripe_types/src/ids.rs index 76dc7298d..ad722fb27 100644 --- a/stripe_types/src/ids.rs +++ b/stripe_types/src/ids.rs @@ -36,6 +36,18 @@ macro_rules! def_id { pub fn as_str(&self) -> &str { self.0.as_str() } + + /// Obtain a reference to the underlying `SmolStr`. + #[inline] + pub fn inner(&self) -> &smol_str::SmolStr { + &self.0 + } + } + + impl stripe_types::AsCursor for $struct_name { + fn as_cursor(&self) -> &str { + self.0.as_str() + } } impl PartialEq for $struct_name { @@ -119,12 +131,24 @@ macro_rules! def_id { self.0.as_str() } + /// Obtain a reference to the underlying `SmolStr`. + #[inline] + pub fn inner(&self) -> &smol_str::SmolStr { + &self.0 + } + /// Check is provided prefix would be a valid prefix for id's of this type pub fn is_valid_prefix(prefix: &str) -> bool { prefix == $prefix $( || prefix == $alt_prefix )* } } + impl stripe_types::AsCursor for $struct_name { + fn as_cursor(&self) -> &str { + self.0.as_str() + } + } + impl PartialEq for $struct_name { fn eq(&self, other: &str) -> bool { self.as_str() == other diff --git a/stripe_types/src/pagination.rs b/stripe_types/src/pagination.rs index 06878ec19..3ad96ae7f 100644 --- a/stripe_types/src/pagination.rs +++ b/stripe_types/src/pagination.rs @@ -3,9 +3,35 @@ use serde::{Deserialize, Serialize}; /// Implemented by types which represent stripe objects. pub trait Object { /// The canonical id type for this object. - type Id; + type Id: AsCursorOpt; /// The id of the object. - fn id(&self) -> Option<&str>; + fn id(&self) -> &Self::Id; +} + +pub trait AsCursorOpt { + fn as_cursor_opt(&self) -> Option<&str>; +} + +pub trait AsCursor { + fn as_cursor(&self) -> &str; +} + +impl AsCursor for smol_str::SmolStr { + fn as_cursor(&self) -> &str { + self.as_str() + } +} + +impl AsCursorOpt for T { + fn as_cursor_opt(&self) -> Option<&str> { + Some(self.as_cursor()) + } +} + +impl AsCursorOpt for Option { + fn as_cursor_opt(&self) -> Option<&str> { + self.as_ref().map(|id| id.as_cursor()) + } } /// A single page of a cursor-paginated list of an object.