1#[derive(Clone,Debug,)]#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
5#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
6pub struct Error {
7pub error: Box<ErrorError>,
8
9}
10#[doc(hidden)]
11pub struct ErrorBuilder {
12 error: Option<Box<ErrorError>>,
13
14}
15
16#[allow(unused_variables, irrefutable_let_patterns, clippy::let_unit_value, clippy::match_single_binding, clippy::single_match)]
17const _: () = {
18 use miniserde::de::{Map, Visitor};
19 use miniserde::json::Value;
20 use miniserde::{make_place, Deserialize, Result};
21 use payjp_types::{MapBuilder, ObjectDeser};
22 use payjp_types::miniserde_helpers::FromValueOpt;
23
24 make_place!(Place);
25
26 impl Deserialize for Error {
27 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
28 Place::new(out)
29 }
30}
31
32struct Builder<'a> {
33 out: &'a mut Option<Error>,
34 builder: ErrorBuilder,
35}
36
37impl Visitor for Place<Error> {
38 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
39 Ok(Box::new(Builder {
40 out: &mut self.out,
41 builder: ErrorBuilder::deser_default(),
42 }))
43 }
44}
45
46impl MapBuilder for ErrorBuilder {
47 type Out = Error;
48 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
49 Ok(match k {
50 "error" => Deserialize::begin(&mut self.error),
51
52 _ => <dyn Visitor>::ignore(),
53 })
54 }
55
56 fn deser_default() -> Self {
57 Self {
58 error: Deserialize::default(),
59
60 }
61 }
62
63 fn take_out(&mut self) -> Option<Self::Out> {
64 let (Some(error),
65) = (self.error.take(),
66) else {
67 return None;
68 };
69 Some(Self::Out { error })
70 }
71}
72
73impl<'a> Map for Builder<'a> {
74 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
75 self.builder.key(k)
76 }
77
78 fn finish(&mut self) -> Result<()> {
79 *self.out = self.builder.take_out();
80 Ok(())
81 }
82}
83
84impl ObjectDeser for Error {
85 type Builder = ErrorBuilder;
86}
87
88impl FromValueOpt for Error {
89 fn from_value(v: Value) -> Option<Self> {
90 let Value::Object(obj) = v else {
91 return None;
92 };
93 let mut b = ErrorBuilder::deser_default();
94 for (k, v) in obj {
95 match k.as_str() {
96 "error" => b.error = FromValueOpt::from_value(v),
97
98 _ => {}
99 }
100 }
101 b.take_out()
102 }
103}
104
105};
106#[derive(Clone,Debug,)]#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
107#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
108pub struct ErrorError {
109 pub charge: Option<String>,
111 pub code: Option<ErrorErrorCode>,
113 pub message: String,
115 pub param: Option<String>,
117 pub status: i64,
119 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
121pub type_: ErrorErrorType,
122
123}
124#[doc(hidden)]
125pub struct ErrorErrorBuilder {
126 charge: Option<Option<String>>,
127code: Option<Option<ErrorErrorCode>>,
128message: Option<String>,
129param: Option<Option<String>>,
130status: Option<i64>,
131type_: Option<ErrorErrorType>,
132
133}
134
135#[allow(unused_variables, irrefutable_let_patterns, clippy::let_unit_value, clippy::match_single_binding, clippy::single_match)]
136const _: () = {
137 use miniserde::de::{Map, Visitor};
138 use miniserde::json::Value;
139 use miniserde::{make_place, Deserialize, Result};
140 use payjp_types::{MapBuilder, ObjectDeser};
141 use payjp_types::miniserde_helpers::FromValueOpt;
142
143 make_place!(Place);
144
145 impl Deserialize for ErrorError {
146 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
147 Place::new(out)
148 }
149}
150
151struct Builder<'a> {
152 out: &'a mut Option<ErrorError>,
153 builder: ErrorErrorBuilder,
154}
155
156impl Visitor for Place<ErrorError> {
157 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
158 Ok(Box::new(Builder {
159 out: &mut self.out,
160 builder: ErrorErrorBuilder::deser_default(),
161 }))
162 }
163}
164
165impl MapBuilder for ErrorErrorBuilder {
166 type Out = ErrorError;
167 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
168 Ok(match k {
169 "charge" => Deserialize::begin(&mut self.charge),
170"code" => Deserialize::begin(&mut self.code),
171"message" => Deserialize::begin(&mut self.message),
172"param" => Deserialize::begin(&mut self.param),
173"status" => Deserialize::begin(&mut self.status),
174"type" => Deserialize::begin(&mut self.type_),
175
176 _ => <dyn Visitor>::ignore(),
177 })
178 }
179
180 fn deser_default() -> Self {
181 Self {
182 charge: Deserialize::default(),
183code: Deserialize::default(),
184message: Deserialize::default(),
185param: Deserialize::default(),
186status: Deserialize::default(),
187type_: Deserialize::default(),
188
189 }
190 }
191
192 fn take_out(&mut self) -> Option<Self::Out> {
193 let (Some(charge),
194Some(code),
195Some(message),
196Some(param),
197Some(status),
198Some(type_),
199) = (self.charge.take(),
200self.code,
201self.message.take(),
202self.param.take(),
203self.status,
204self.type_,
205) else {
206 return None;
207 };
208 Some(Self::Out { charge,code,message,param,status,type_ })
209 }
210}
211
212impl<'a> Map for Builder<'a> {
213 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
214 self.builder.key(k)
215 }
216
217 fn finish(&mut self) -> Result<()> {
218 *self.out = self.builder.take_out();
219 Ok(())
220 }
221}
222
223impl ObjectDeser for ErrorError {
224 type Builder = ErrorErrorBuilder;
225}
226
227impl FromValueOpt for ErrorError {
228 fn from_value(v: Value) -> Option<Self> {
229 let Value::Object(obj) = v else {
230 return None;
231 };
232 let mut b = ErrorErrorBuilder::deser_default();
233 for (k, v) in obj {
234 match k.as_str() {
235 "charge" => b.charge = FromValueOpt::from_value(v),
236"code" => b.code = FromValueOpt::from_value(v),
237"message" => b.message = FromValueOpt::from_value(v),
238"param" => b.param = FromValueOpt::from_value(v),
239"status" => b.status = FromValueOpt::from_value(v),
240"type" => b.type_ = FromValueOpt::from_value(v),
241
242 _ => {}
243 }
244 }
245 b.take_out()
246 }
247}
248
249};
250#[derive(Copy,Clone,Eq, PartialEq,)]#[non_exhaustive]pub enum ErrorErrorCode {
252InvalidNumber,
253InvalidCvc,
254InvalidExpirationDate,
255IncorrectCardData,
256InvalidExpiryMonth,
257InvalidExpiryYear,
258ExpiredCard,
259CardDeclined,
260CardFlagged,
261ProcessingError,
262MissingCard,
263UnacceptableBrand,
264InvalidId,
265NoApiKey,
266InvalidApiKey,
267InvalidPlan,
268InvalidExpiryDays,
269UnnecessaryExpiryDays,
270InvalidFlexibleId,
271InvalidTimestamp,
272InvalidTrialEnd,
273InvalidStringLength,
274InvalidCountry,
275InvalidCurrency,
276InvalidAddressZip,
277InvalidAmount,
278InvalidPlanAmount,
279InvalidCard,
280InvalidCardName,
281InvalidCardCountry,
282InvalidCardAddressZip,
283InvalidCardAddressState,
284InvalidCardAddressCity,
285InvalidCardAddressLine,
286InvalidCustomer,
287InvalidBoolean,
288InvalidEmail,
289NoAllowedParam,
290NoParam,
291InvalidQuerystring,
292MissingParam,
293InvalidParamKey,
294NoPaymentMethod,
295PaymentMethodDuplicate,
296PaymentMethodDuplicateIncludingCustomer,
297FailedPayment,
298InvalidRefundAmount,
299AlreadyRefunded,
300InvalidAmountToNotCaptured,
301RefundAmountGtNet,
302CaptureAmountGtNet,
303InvalidRefundReason,
304AlreadyCaptured,
305CantCaptureRefundedCharge,
306CantReauthRefundedCharge,
307ChargeExpired,
308AlreadyExistId,
309TokenAlreadyUsed,
310AlreadyHaveCard,
311DontHasThisCard,
312DoesntHaveCard,
313AlreadyHaveTheSameCard,
314InvalidInterval,
315InvalidTrialDays,
316InvalidBillingDay,
317BillingDayForNonMonthlyPlan,
318ExistSubscribers,
319AlreadySubscribed,
320AlreadyCanceled,
321AlreadyPaused,
322SubscriptionWorked,
323CannotChangeProrateStatus,
324TooManyMetadataKeys,
325InvalidMetadataKey,
326InvalidMetadataValue,
327ApplePayDisabledInLivemode,
328InvalidApplePayToken,
329TestCardOnLivemode,
330NotActivatedAccount,
331PayjpWrong,
332PgWrong,
333NotFound,
334NotAllowedMethod,
335OverCapacity,
336RefundLimitExceeded,
337CannotProratedRefundOfSubscription,
338ThreeDSecureIncompleted,
339ThreeDSecureFailed,
340NotInThreeDSecureFlow,
341UnverifiedToken,
342InvalidOwnerType,
343Unknown,
344
345}
346impl ErrorErrorCode {
347 pub fn as_str(self) -> &'static str {
348 use ErrorErrorCode::*;
349 match self {
350InvalidNumber => "invalid_number",
351InvalidCvc => "invalid_cvc",
352InvalidExpirationDate => "invalid_expiration_date",
353IncorrectCardData => "incorrect_card_data",
354InvalidExpiryMonth => "invalid_expiry_month",
355InvalidExpiryYear => "invalid_expiry_year",
356ExpiredCard => "expired_card",
357CardDeclined => "card_declined",
358CardFlagged => "card_flagged",
359ProcessingError => "processing_error",
360MissingCard => "missing_card",
361UnacceptableBrand => "unacceptable_brand",
362InvalidId => "invalid_id",
363NoApiKey => "no_api_key",
364InvalidApiKey => "invalid_api_key",
365InvalidPlan => "invalid_plan",
366InvalidExpiryDays => "invalid_expiry_days",
367UnnecessaryExpiryDays => "unnecessary_expiry_days",
368InvalidFlexibleId => "invalid_flexible_id",
369InvalidTimestamp => "invalid_timestamp",
370InvalidTrialEnd => "invalid_trial_end",
371InvalidStringLength => "invalid_string_length",
372InvalidCountry => "invalid_country",
373InvalidCurrency => "invalid_currency",
374InvalidAddressZip => "invalid_address_zip",
375InvalidAmount => "invalid_amount",
376InvalidPlanAmount => "invalid_plan_amount",
377InvalidCard => "invalid_card",
378InvalidCardName => "invalid_card_name",
379InvalidCardCountry => "invalid_card_country",
380InvalidCardAddressZip => "invalid_card_address_zip",
381InvalidCardAddressState => "invalid_card_address_state",
382InvalidCardAddressCity => "invalid_card_address_city",
383InvalidCardAddressLine => "invalid_card_address_line",
384InvalidCustomer => "invalid_customer",
385InvalidBoolean => "invalid_boolean",
386InvalidEmail => "invalid_email",
387NoAllowedParam => "no_allowed_param",
388NoParam => "no_param",
389InvalidQuerystring => "invalid_querystring",
390MissingParam => "missing_param",
391InvalidParamKey => "invalid_param_key",
392NoPaymentMethod => "no_payment_method",
393PaymentMethodDuplicate => "payment_method_duplicate",
394PaymentMethodDuplicateIncludingCustomer => "payment_method_duplicate_including_customer",
395FailedPayment => "failed_payment",
396InvalidRefundAmount => "invalid_refund_amount",
397AlreadyRefunded => "already_refunded",
398InvalidAmountToNotCaptured => "invalid_amount_to_not_captured",
399RefundAmountGtNet => "refund_amount_gt_net",
400CaptureAmountGtNet => "capture_amount_gt_net",
401InvalidRefundReason => "invalid_refund_reason",
402AlreadyCaptured => "already_captured",
403CantCaptureRefundedCharge => "cant_capture_refunded_charge",
404CantReauthRefundedCharge => "cant_reauth_refunded_charge",
405ChargeExpired => "charge_expired",
406AlreadyExistId => "already_exist_id",
407TokenAlreadyUsed => "token_already_used",
408AlreadyHaveCard => "already_have_card",
409DontHasThisCard => "dont_has_this_card",
410DoesntHaveCard => "doesnt_have_card",
411AlreadyHaveTheSameCard => "already_have_the_same_card",
412InvalidInterval => "invalid_interval",
413InvalidTrialDays => "invalid_trial_days",
414InvalidBillingDay => "invalid_billing_day",
415BillingDayForNonMonthlyPlan => "billing_day_for_non_monthly_plan",
416ExistSubscribers => "exist_subscribers",
417AlreadySubscribed => "already_subscribed",
418AlreadyCanceled => "already_canceled",
419AlreadyPaused => "already_paused",
420SubscriptionWorked => "subscription_worked",
421CannotChangeProrateStatus => "cannot_change_prorate_status",
422TooManyMetadataKeys => "too_many_metadata_keys",
423InvalidMetadataKey => "invalid_metadata_key",
424InvalidMetadataValue => "invalid_metadata_value",
425ApplePayDisabledInLivemode => "apple_pay_disabled_in_livemode",
426InvalidApplePayToken => "invalid_apple_pay_token",
427TestCardOnLivemode => "test_card_on_livemode",
428NotActivatedAccount => "not_activated_account",
429PayjpWrong => "payjp_wrong",
430PgWrong => "pg_wrong",
431NotFound => "not_found",
432NotAllowedMethod => "not_allowed_method",
433OverCapacity => "over_capacity",
434RefundLimitExceeded => "refund_limit_exceeded",
435CannotProratedRefundOfSubscription => "cannot_prorated_refund_of_subscription",
436ThreeDSecureIncompleted => "three_d_secure_incompleted",
437ThreeDSecureFailed => "three_d_secure_failed",
438NotInThreeDSecureFlow => "not_in_three_d_secure_flow",
439UnverifiedToken => "unverified_token",
440InvalidOwnerType => "invalid_owner_type",
441Unknown => "unknown",
442
443 }
444 }
445}
446
447impl std::str::FromStr for ErrorErrorCode {
448 type Err = std::convert::Infallible;
449 fn from_str(s: &str) -> Result<Self, Self::Err> {
450 use ErrorErrorCode::*;
451 match s {
452 "invalid_number" => Ok(InvalidNumber),
453"invalid_cvc" => Ok(InvalidCvc),
454"invalid_expiration_date" => Ok(InvalidExpirationDate),
455"incorrect_card_data" => Ok(IncorrectCardData),
456"invalid_expiry_month" => Ok(InvalidExpiryMonth),
457"invalid_expiry_year" => Ok(InvalidExpiryYear),
458"expired_card" => Ok(ExpiredCard),
459"card_declined" => Ok(CardDeclined),
460"card_flagged" => Ok(CardFlagged),
461"processing_error" => Ok(ProcessingError),
462"missing_card" => Ok(MissingCard),
463"unacceptable_brand" => Ok(UnacceptableBrand),
464"invalid_id" => Ok(InvalidId),
465"no_api_key" => Ok(NoApiKey),
466"invalid_api_key" => Ok(InvalidApiKey),
467"invalid_plan" => Ok(InvalidPlan),
468"invalid_expiry_days" => Ok(InvalidExpiryDays),
469"unnecessary_expiry_days" => Ok(UnnecessaryExpiryDays),
470"invalid_flexible_id" => Ok(InvalidFlexibleId),
471"invalid_timestamp" => Ok(InvalidTimestamp),
472"invalid_trial_end" => Ok(InvalidTrialEnd),
473"invalid_string_length" => Ok(InvalidStringLength),
474"invalid_country" => Ok(InvalidCountry),
475"invalid_currency" => Ok(InvalidCurrency),
476"invalid_address_zip" => Ok(InvalidAddressZip),
477"invalid_amount" => Ok(InvalidAmount),
478"invalid_plan_amount" => Ok(InvalidPlanAmount),
479"invalid_card" => Ok(InvalidCard),
480"invalid_card_name" => Ok(InvalidCardName),
481"invalid_card_country" => Ok(InvalidCardCountry),
482"invalid_card_address_zip" => Ok(InvalidCardAddressZip),
483"invalid_card_address_state" => Ok(InvalidCardAddressState),
484"invalid_card_address_city" => Ok(InvalidCardAddressCity),
485"invalid_card_address_line" => Ok(InvalidCardAddressLine),
486"invalid_customer" => Ok(InvalidCustomer),
487"invalid_boolean" => Ok(InvalidBoolean),
488"invalid_email" => Ok(InvalidEmail),
489"no_allowed_param" => Ok(NoAllowedParam),
490"no_param" => Ok(NoParam),
491"invalid_querystring" => Ok(InvalidQuerystring),
492"missing_param" => Ok(MissingParam),
493"invalid_param_key" => Ok(InvalidParamKey),
494"no_payment_method" => Ok(NoPaymentMethod),
495"payment_method_duplicate" => Ok(PaymentMethodDuplicate),
496"payment_method_duplicate_including_customer" => Ok(PaymentMethodDuplicateIncludingCustomer),
497"failed_payment" => Ok(FailedPayment),
498"invalid_refund_amount" => Ok(InvalidRefundAmount),
499"already_refunded" => Ok(AlreadyRefunded),
500"invalid_amount_to_not_captured" => Ok(InvalidAmountToNotCaptured),
501"refund_amount_gt_net" => Ok(RefundAmountGtNet),
502"capture_amount_gt_net" => Ok(CaptureAmountGtNet),
503"invalid_refund_reason" => Ok(InvalidRefundReason),
504"already_captured" => Ok(AlreadyCaptured),
505"cant_capture_refunded_charge" => Ok(CantCaptureRefundedCharge),
506"cant_reauth_refunded_charge" => Ok(CantReauthRefundedCharge),
507"charge_expired" => Ok(ChargeExpired),
508"already_exist_id" => Ok(AlreadyExistId),
509"token_already_used" => Ok(TokenAlreadyUsed),
510"already_have_card" => Ok(AlreadyHaveCard),
511"dont_has_this_card" => Ok(DontHasThisCard),
512"doesnt_have_card" => Ok(DoesntHaveCard),
513"already_have_the_same_card" => Ok(AlreadyHaveTheSameCard),
514"invalid_interval" => Ok(InvalidInterval),
515"invalid_trial_days" => Ok(InvalidTrialDays),
516"invalid_billing_day" => Ok(InvalidBillingDay),
517"billing_day_for_non_monthly_plan" => Ok(BillingDayForNonMonthlyPlan),
518"exist_subscribers" => Ok(ExistSubscribers),
519"already_subscribed" => Ok(AlreadySubscribed),
520"already_canceled" => Ok(AlreadyCanceled),
521"already_paused" => Ok(AlreadyPaused),
522"subscription_worked" => Ok(SubscriptionWorked),
523"cannot_change_prorate_status" => Ok(CannotChangeProrateStatus),
524"too_many_metadata_keys" => Ok(TooManyMetadataKeys),
525"invalid_metadata_key" => Ok(InvalidMetadataKey),
526"invalid_metadata_value" => Ok(InvalidMetadataValue),
527"apple_pay_disabled_in_livemode" => Ok(ApplePayDisabledInLivemode),
528"invalid_apple_pay_token" => Ok(InvalidApplePayToken),
529"test_card_on_livemode" => Ok(TestCardOnLivemode),
530"not_activated_account" => Ok(NotActivatedAccount),
531"payjp_wrong" => Ok(PayjpWrong),
532"pg_wrong" => Ok(PgWrong),
533"not_found" => Ok(NotFound),
534"not_allowed_method" => Ok(NotAllowedMethod),
535"over_capacity" => Ok(OverCapacity),
536"refund_limit_exceeded" => Ok(RefundLimitExceeded),
537"cannot_prorated_refund_of_subscription" => Ok(CannotProratedRefundOfSubscription),
538"three_d_secure_incompleted" => Ok(ThreeDSecureIncompleted),
539"three_d_secure_failed" => Ok(ThreeDSecureFailed),
540"not_in_three_d_secure_flow" => Ok(NotInThreeDSecureFlow),
541"unverified_token" => Ok(UnverifiedToken),
542"invalid_owner_type" => Ok(InvalidOwnerType),
543_ => Ok(Self::Unknown)
544
545 }
546 }
547}
548impl std::fmt::Display for ErrorErrorCode {
549 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
550 f.write_str(self.as_str())
551 }
552}
553
554impl std::fmt::Debug for ErrorErrorCode {
555 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
556 f.write_str(self.as_str())
557 }
558}
559#[cfg(feature = "serialize")]
560impl serde::Serialize for ErrorErrorCode {
561 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
562 serializer.serialize_str(self.as_str())
563 }
564}
565impl miniserde::Deserialize for ErrorErrorCode {
566 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
567 crate::Place::new(out)
568 }
569}
570
571impl miniserde::de::Visitor for crate::Place<ErrorErrorCode> {
572 fn string(&mut self, s: &str) -> miniserde::Result<()> {
573 use std::str::FromStr;
574 self.out = Some(ErrorErrorCode::from_str(s).unwrap());
575 Ok(())
576 }
577}
578
579payjp_types::impl_from_val_with_from_str!(ErrorErrorCode);
580#[cfg(feature = "deserialize")]
581impl<'de> serde::Deserialize<'de> for ErrorErrorCode {
582 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
583 use std::str::FromStr;
584 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
585 Ok(Self::from_str(&s).unwrap())
586 }
587}
588#[derive(Copy,Clone,Eq, PartialEq,)]pub enum ErrorErrorType {
590ClientError,
591CardError,
592ServerError,
593NotAllowedMethodError,
594AuthError,
595InvalidRequestError,
596
597}
598impl ErrorErrorType {
599 pub fn as_str(self) -> &'static str {
600 use ErrorErrorType::*;
601 match self {
602ClientError => "client_error",
603CardError => "card_error",
604ServerError => "server_error",
605NotAllowedMethodError => "not_allowed_method_error",
606AuthError => "auth_error",
607InvalidRequestError => "invalid_request_error",
608
609 }
610 }
611}
612
613impl std::str::FromStr for ErrorErrorType {
614 type Err = payjp_types::ParseError;
615 fn from_str(s: &str) -> Result<Self, Self::Err> {
616 use ErrorErrorType::*;
617 match s {
618 "client_error" => Ok(ClientError),
619"card_error" => Ok(CardError),
620"server_error" => Ok(ServerError),
621"not_allowed_method_error" => Ok(NotAllowedMethodError),
622"auth_error" => Ok(AuthError),
623"invalid_request_error" => Ok(InvalidRequestError),
624_ => Err(payjp_types::ParseError)
625
626 }
627 }
628}
629impl std::fmt::Display for ErrorErrorType {
630 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
631 f.write_str(self.as_str())
632 }
633}
634
635impl std::fmt::Debug for ErrorErrorType {
636 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
637 f.write_str(self.as_str())
638 }
639}
640#[cfg(feature = "serialize")]
641impl serde::Serialize for ErrorErrorType {
642 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
643 serializer.serialize_str(self.as_str())
644 }
645}
646impl miniserde::Deserialize for ErrorErrorType {
647 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
648 crate::Place::new(out)
649 }
650}
651
652impl miniserde::de::Visitor for crate::Place<ErrorErrorType> {
653 fn string(&mut self, s: &str) -> miniserde::Result<()> {
654 use std::str::FromStr;
655 self.out = Some(ErrorErrorType::from_str(s).map_err(|_| miniserde::Error)?);
656 Ok(())
657 }
658}
659
660payjp_types::impl_from_val_with_from_str!(ErrorErrorType);
661#[cfg(feature = "deserialize")]
662impl<'de> serde::Deserialize<'de> for ErrorErrorType {
663 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
664 use std::str::FromStr;
665 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
666 Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ErrorErrorType"))
667 }
668}