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                _ => <dyn Visitor>::ignore(),
55            })
56        }
57
58        fn deser_default() -> Self {
59            Self { status: Deserialize::default() }
60        }
61
62        fn take_out(&mut self) -> Option<Self::Out> {
63            let (Some(status),) = (self.status,) else {
64                return None;
65            };
66            Some(Self::Out { status })
67        }
68    }
69
70    impl Map for Builder<'_> {
71        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72            self.builder.key(k)
73        }
74
75        fn finish(&mut self) -> Result<()> {
76            *self.out = self.builder.take_out();
77            Ok(())
78        }
79    }
80
81    impl ObjectDeser for VerificationSessionRedaction {
82        type Builder = VerificationSessionRedactionBuilder;
83    }
84
85    impl FromValueOpt for VerificationSessionRedaction {
86        fn from_value(v: Value) -> Option<Self> {
87            let Value::Object(obj) = v else {
88                return None;
89            };
90            let mut b = VerificationSessionRedactionBuilder::deser_default();
91            for (k, v) in obj {
92                match k.as_str() {
93                    "status" => b.status = FromValueOpt::from_value(v),
94                    _ => {}
95                }
96            }
97            b.take_out()
98        }
99    }
100};
101/// Indicates whether this object and its related objects have been redacted or not.
102#[derive(Copy, Clone, Eq, PartialEq)]
103pub enum VerificationSessionRedactionStatus {
104    Processing,
105    Redacted,
106}
107impl VerificationSessionRedactionStatus {
108    pub fn as_str(self) -> &'static str {
109        use VerificationSessionRedactionStatus::*;
110        match self {
111            Processing => "processing",
112            Redacted => "redacted",
113        }
114    }
115}
116
117impl std::str::FromStr for VerificationSessionRedactionStatus {
118    type Err = stripe_types::StripeParseError;
119    fn from_str(s: &str) -> Result<Self, Self::Err> {
120        use VerificationSessionRedactionStatus::*;
121        match s {
122            "processing" => Ok(Processing),
123            "redacted" => Ok(Redacted),
124            _ => Err(stripe_types::StripeParseError),
125        }
126    }
127}
128impl std::fmt::Display for VerificationSessionRedactionStatus {
129    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
130        f.write_str(self.as_str())
131    }
132}
133
134impl std::fmt::Debug for VerificationSessionRedactionStatus {
135    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
136        f.write_str(self.as_str())
137    }
138}
139#[cfg(feature = "serialize")]
140impl serde::Serialize for VerificationSessionRedactionStatus {
141    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
142    where
143        S: serde::Serializer,
144    {
145        serializer.serialize_str(self.as_str())
146    }
147}
148impl miniserde::Deserialize for VerificationSessionRedactionStatus {
149    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
150        crate::Place::new(out)
151    }
152}
153
154impl miniserde::de::Visitor for crate::Place<VerificationSessionRedactionStatus> {
155    fn string(&mut self, s: &str) -> miniserde::Result<()> {
156        use std::str::FromStr;
157        self.out =
158            Some(VerificationSessionRedactionStatus::from_str(s).map_err(|_| miniserde::Error)?);
159        Ok(())
160    }
161}
162
163stripe_types::impl_from_val_with_from_str!(VerificationSessionRedactionStatus);
164#[cfg(feature = "deserialize")]
165impl<'de> serde::Deserialize<'de> for VerificationSessionRedactionStatus {
166    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
167        use std::str::FromStr;
168        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
169        Self::from_str(&s).map_err(|_| {
170            serde::de::Error::custom("Unknown value for VerificationSessionRedactionStatus")
171        })
172    }
173}