stripe_shared/
refund_next_action.rs

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