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