Skip to main content

rustauth_plugins/one_tap/
options.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct OneTapOptions {
6    #[serde(default)]
7    pub disable_signup: bool,
8    #[serde(default, skip_serializing_if = "Option::is_none")]
9    pub client_id: Option<String>,
10}
11
12impl OneTapOptions {
13    #[must_use]
14    pub fn builder() -> OneTapOptionsBuilder {
15        OneTapOptionsBuilder::default()
16    }
17}
18
19#[derive(Debug, Clone, Default)]
20pub struct OneTapOptionsBuilder {
21    disable_signup: Option<bool>,
22    client_id: Option<Option<String>>,
23}
24
25impl OneTapOptionsBuilder {
26    #[must_use]
27    pub fn disable_signup(mut self, disable_signup: bool) -> Self {
28        self.disable_signup = Some(disable_signup);
29        self
30    }
31
32    #[must_use]
33    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
34        self.client_id = Some(Some(client_id.into()));
35        self
36    }
37
38    #[must_use]
39    pub fn build(self) -> OneTapOptions {
40        let defaults = OneTapOptions::default();
41        OneTapOptions {
42            disable_signup: self.disable_signup.unwrap_or(defaults.disable_signup),
43            client_id: self.client_id.unwrap_or(defaults.client_id),
44        }
45    }
46}