stripe_misc/
verification_session_redaction.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct VerificationSessionRedaction {
5    /// Indicates whether this object and its related objects have been redacted or not.
6    pub status: VerificationSessionRedactionStatus,
7}
8#[doc(hidden)]
9pub struct VerificationSessionRedactionBuilder {
10    status: Option<VerificationSessionRedactionStatus>,
11}
12
13#[allow(
14    unused_variables,
15    irrefutable_let_patterns,
16    clippy::let_unit_value,
17    clippy::match_single_binding,
18    clippy::single_match
19)]
20const _: () = {
21    use miniserde::de::{Map, Visitor};
22    use miniserde::json::Value;
23    use miniserde::{Deserialize, Result, make_place};
24    use stripe_types::miniserde_helpers::FromValueOpt;
25    use stripe_types::{MapBuilder, ObjectDeser};
26
27    make_place!(Place);
28
29    impl Deserialize for VerificationSessionRedaction {
30        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
31            Place::new(out)
32        }
33    }
34
35    struct Builder<'a> {
36        out: &'a mut Option<VerificationSessionRedaction>,
37        builder: VerificationSessionRedactionBuilder,
38    }
39
40    impl Visitor for Place<VerificationSessionRedaction> {
41        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
42            Ok(Box::new(Builder {
43                out: &mut self.out,
44                builder: VerificationSessionRedactionBuilder::deser_default(),
45            }))
46        }
47    }
48
49    impl MapBuilder for VerificationSessionRedactionBuilder {
50        type Out = VerificationSessionRedaction;
51        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
52            Ok(match k {
53                "status" => Deserialize::begin(&mut self.status),
54
55                _ => <dyn Visitor>::ignore(),
56            })
57        }
58
59        fn deser_default() -> Self {
60            Self { status: Deserialize::default() }
61        }
62
63        fn take_out(&mut self) -> Option<Self::Out> {
64            let (Some(status),) = (self.status,) else {
65                return None;
66            };
67            Some(Self::Out { status })
68        }
69    }
70
71    impl Map for Builder<'_> {
72        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
73            self.builder.key(k)
74        }
75
76        fn finish(&mut self) -> Result<()> {
77            *self.out = self.builder.take_out();
78            Ok(())
79        }
80    }
81
82    impl ObjectDeser for VerificationSessionRedaction {
83        type Builder = VerificationSessionRedactionBuilder;
84    }
85
86    impl FromValueOpt for VerificationSessionRedaction {
87        fn from_value(v: Value) -> Option<Self> {
88            let Value::Object(obj) = v else {
89                return None;
90            };
91            let mut b = VerificationSessionRedactionBuilder::deser_default();
92            for (k, v) in obj {
93                match k.as_str() {
94                    "status" => b.status = FromValueOpt::from_value(v),
95
96                    _ => {}
97                }
98            }
99            b.take_out()
100        }
101    }
102};
103/// Indicates whether this object and its related objects have been redacted or not.
104#[derive(Copy, Clone, Eq, PartialEq)]
105pub enum VerificationSessionRedactionStatus {
106    Processing,
107    Redacted,
108}
109impl VerificationSessionRedactionStatus {
110    pub fn as_str(self) -> &'static str {
111        use VerificationSessionRedactionStatus::*;
112        match self {
113            Processing => "processing",
114            Redacted => "redacted",
115        }
116    }
117}
118
119impl std::str::FromStr for VerificationSessionRedactionStatus {
120    type Err = stripe_types::StripeParseError;
121    fn from_str(s: &str) -> Result<Self, Self::Err> {
122        use VerificationSessionRedactionStatus::*;
123        match s {
124            "processing" => Ok(Processing),
125            "redacted" => Ok(Redacted),
126            _ => Err(stripe_types::StripeParseError),
127        }
128    }
129}
130impl std::fmt::Display for VerificationSessionRedactionStatus {
131    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
132        f.write_str(self.as_str())
133    }
134}
135
136impl std::fmt::Debug for VerificationSessionRedactionStatus {
137    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
138        f.write_str(self.as_str())
139    }
140}
141#[cfg(feature = "serialize")]
142impl serde::Serialize for VerificationSessionRedactionStatus {
143    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
144    where
145        S: serde::Serializer,
146    {
147        serializer.serialize_str(self.as_str())
148    }
149}
150impl miniserde::Deserialize for VerificationSessionRedactionStatus {
151    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
152        crate::Place::new(out)
153    }
154}
155
156impl miniserde::de::Visitor for crate::Place<VerificationSessionRedactionStatus> {
157    fn string(&mut self, s: &str) -> miniserde::Result<()> {
158        use std::str::FromStr;
159        self.out =
160            Some(VerificationSessionRedactionStatus::from_str(s).map_err(|_| miniserde::Error)?);
161        Ok(())
162    }
163}
164
165stripe_types::impl_from_val_with_from_str!(VerificationSessionRedactionStatus);
166#[cfg(feature = "deserialize")]
167impl<'de> serde::Deserialize<'de> for VerificationSessionRedactionStatus {
168    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
169        use std::str::FromStr;
170        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
171        Self::from_str(&s).map_err(|_| {
172            serde::de::Error::custom("Unknown value for VerificationSessionRedactionStatus")
173        })
174    }
175}