async-stripe-misc 1.0.0-rc.8

API bindings for the Stripe HTTP API
Documentation
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct GelatoSessionMatchingOptions {
    /// Strictness of the DOB matching policy to apply.
    pub dob: Option<GelatoSessionMatchingOptionsDob>,
    /// Strictness of the name matching policy to apply.
    pub name: Option<GelatoSessionMatchingOptionsName>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for GelatoSessionMatchingOptions {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("GelatoSessionMatchingOptions").finish_non_exhaustive()
    }
}
#[doc(hidden)]
pub struct GelatoSessionMatchingOptionsBuilder {
    dob: Option<Option<GelatoSessionMatchingOptionsDob>>,
    name: Option<Option<GelatoSessionMatchingOptionsName>>,
}

#[allow(
    unused_variables,
    irrefutable_let_patterns,
    clippy::let_unit_value,
    clippy::match_single_binding,
    clippy::single_match
)]
const _: () = {
    use miniserde::de::{Map, Visitor};
    use miniserde::json::Value;
    use miniserde::{Deserialize, Result, make_place};
    use stripe_types::miniserde_helpers::FromValueOpt;
    use stripe_types::{MapBuilder, ObjectDeser};

    make_place!(Place);

    impl Deserialize for GelatoSessionMatchingOptions {
        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
            Place::new(out)
        }
    }

    struct Builder<'a> {
        out: &'a mut Option<GelatoSessionMatchingOptions>,
        builder: GelatoSessionMatchingOptionsBuilder,
    }

    impl Visitor for Place<GelatoSessionMatchingOptions> {
        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
            Ok(Box::new(Builder {
                out: &mut self.out,
                builder: GelatoSessionMatchingOptionsBuilder::deser_default(),
            }))
        }
    }

    impl MapBuilder for GelatoSessionMatchingOptionsBuilder {
        type Out = GelatoSessionMatchingOptions;
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            Ok(match k {
                "dob" => Deserialize::begin(&mut self.dob),
                "name" => Deserialize::begin(&mut self.name),
                _ => <dyn Visitor>::ignore(),
            })
        }

        fn deser_default() -> Self {
            Self { dob: Some(None), name: Some(None) }
        }

        fn take_out(&mut self) -> Option<Self::Out> {
            let (Some(dob), Some(name)) = (self.dob.take(), self.name.take()) else {
                return None;
            };
            Some(Self::Out { dob, name })
        }
    }

    impl Map for Builder<'_> {
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            self.builder.key(k)
        }

        fn finish(&mut self) -> Result<()> {
            *self.out = self.builder.take_out();
            Ok(())
        }
    }

    impl ObjectDeser for GelatoSessionMatchingOptions {
        type Builder = GelatoSessionMatchingOptionsBuilder;
    }

    impl FromValueOpt for GelatoSessionMatchingOptions {
        fn from_value(v: Value) -> Option<Self> {
            let Value::Object(obj) = v else {
                return None;
            };
            let mut b = GelatoSessionMatchingOptionsBuilder::deser_default();
            for (k, v) in obj {
                match k.as_str() {
                    "dob" => b.dob = FromValueOpt::from_value(v),
                    "name" => b.name = FromValueOpt::from_value(v),
                    _ => {}
                }
            }
            b.take_out()
        }
    }
};
/// Strictness of the DOB matching policy to apply.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum GelatoSessionMatchingOptionsDob {
    None,
    Similar,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl GelatoSessionMatchingOptionsDob {
    pub fn as_str(&self) -> &str {
        use GelatoSessionMatchingOptionsDob::*;
        match self {
            None => "none",
            Similar => "similar",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for GelatoSessionMatchingOptionsDob {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use GelatoSessionMatchingOptionsDob::*;
        match s {
            "none" => Ok(None),
            "similar" => Ok(Similar),
            v => {
                tracing::warn!(
                    "Unknown value '{}' for enum '{}'",
                    v,
                    "GelatoSessionMatchingOptionsDob"
                );
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for GelatoSessionMatchingOptionsDob {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for GelatoSessionMatchingOptionsDob {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for GelatoSessionMatchingOptionsDob {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(GelatoSessionMatchingOptionsDob)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for GelatoSessionMatchingOptionsDob {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for GelatoSessionMatchingOptionsDob {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<GelatoSessionMatchingOptionsDob> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(GelatoSessionMatchingOptionsDob::from_str(s).expect("infallible"));
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(GelatoSessionMatchingOptionsDob);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for GelatoSessionMatchingOptionsDob {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
/// Strictness of the name matching policy to apply.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum GelatoSessionMatchingOptionsName {
    None,
    Similar,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl GelatoSessionMatchingOptionsName {
    pub fn as_str(&self) -> &str {
        use GelatoSessionMatchingOptionsName::*;
        match self {
            None => "none",
            Similar => "similar",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for GelatoSessionMatchingOptionsName {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use GelatoSessionMatchingOptionsName::*;
        match s {
            "none" => Ok(None),
            "similar" => Ok(Similar),
            v => {
                tracing::warn!(
                    "Unknown value '{}' for enum '{}'",
                    v,
                    "GelatoSessionMatchingOptionsName"
                );
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for GelatoSessionMatchingOptionsName {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for GelatoSessionMatchingOptionsName {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for GelatoSessionMatchingOptionsName {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(GelatoSessionMatchingOptionsName)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for GelatoSessionMatchingOptionsName {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for GelatoSessionMatchingOptionsName {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<GelatoSessionMatchingOptionsName> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(GelatoSessionMatchingOptionsName::from_str(s).expect("infallible"));
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(GelatoSessionMatchingOptionsName);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for GelatoSessionMatchingOptionsName {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}