stripe_shared/
subscriptions_resource_billing_schedules.rs1#[derive(Clone)]
3#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
4#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
5#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
6pub struct SubscriptionsResourceBillingSchedules {
7 pub applies_to: Option<Vec<stripe_shared::SubscriptionsResourceBillingSchedulesAppliesTo>>,
9 pub bill_until: stripe_shared::SubscriptionsResourceBillingSchedulesBillUntil,
10 pub key: String,
12}
13#[cfg(feature = "redact-generated-debug")]
14impl std::fmt::Debug for SubscriptionsResourceBillingSchedules {
15 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16 f.debug_struct("SubscriptionsResourceBillingSchedules").finish_non_exhaustive()
17 }
18}
19#[doc(hidden)]
20pub struct SubscriptionsResourceBillingSchedulesBuilder {
21 applies_to: Option<Option<Vec<stripe_shared::SubscriptionsResourceBillingSchedulesAppliesTo>>>,
22 bill_until: Option<stripe_shared::SubscriptionsResourceBillingSchedulesBillUntil>,
23 key: Option<String>,
24}
25
26#[allow(
27 unused_variables,
28 irrefutable_let_patterns,
29 clippy::let_unit_value,
30 clippy::match_single_binding,
31 clippy::single_match
32)]
33const _: () = {
34 use miniserde::de::{Map, Visitor};
35 use miniserde::json::Value;
36 use miniserde::{Deserialize, Result, make_place};
37 use stripe_types::miniserde_helpers::FromValueOpt;
38 use stripe_types::{MapBuilder, ObjectDeser};
39
40 make_place!(Place);
41
42 impl Deserialize for SubscriptionsResourceBillingSchedules {
43 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
44 Place::new(out)
45 }
46 }
47
48 struct Builder<'a> {
49 out: &'a mut Option<SubscriptionsResourceBillingSchedules>,
50 builder: SubscriptionsResourceBillingSchedulesBuilder,
51 }
52
53 impl Visitor for Place<SubscriptionsResourceBillingSchedules> {
54 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
55 Ok(Box::new(Builder {
56 out: &mut self.out,
57 builder: SubscriptionsResourceBillingSchedulesBuilder::deser_default(),
58 }))
59 }
60 }
61
62 impl MapBuilder for SubscriptionsResourceBillingSchedulesBuilder {
63 type Out = SubscriptionsResourceBillingSchedules;
64 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
65 Ok(match k {
66 "applies_to" => Deserialize::begin(&mut self.applies_to),
67 "bill_until" => Deserialize::begin(&mut self.bill_until),
68 "key" => Deserialize::begin(&mut self.key),
69 _ => <dyn Visitor>::ignore(),
70 })
71 }
72
73 fn deser_default() -> Self {
74 Self { applies_to: Some(None), bill_until: None, key: None }
75 }
76
77 fn take_out(&mut self) -> Option<Self::Out> {
78 let (Some(applies_to), Some(bill_until), Some(key)) =
79 (self.applies_to.take(), self.bill_until.take(), self.key.take())
80 else {
81 return None;
82 };
83 Some(Self::Out { applies_to, bill_until, key })
84 }
85 }
86
87 impl Map for Builder<'_> {
88 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89 self.builder.key(k)
90 }
91
92 fn finish(&mut self) -> Result<()> {
93 *self.out = self.builder.take_out();
94 Ok(())
95 }
96 }
97
98 impl ObjectDeser for SubscriptionsResourceBillingSchedules {
99 type Builder = SubscriptionsResourceBillingSchedulesBuilder;
100 }
101
102 impl FromValueOpt for SubscriptionsResourceBillingSchedules {
103 fn from_value(v: Value) -> Option<Self> {
104 let Value::Object(obj) = v else {
105 return None;
106 };
107 let mut b = SubscriptionsResourceBillingSchedulesBuilder::deser_default();
108 for (k, v) in obj {
109 match k.as_str() {
110 "applies_to" => b.applies_to = FromValueOpt::from_value(v),
111 "bill_until" => b.bill_until = FromValueOpt::from_value(v),
112 "key" => b.key = FromValueOpt::from_value(v),
113 _ => {}
114 }
115 }
116 b.take_out()
117 }
118 }
119};