// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.ocho.auth.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

//! Generated bindings for the `app.ocho.auth` Lexicon namespace/module.
pub mod at_proto_callback;
pub mod authorize;
pub mod github_callback;
pub mod google_callback;
pub mod request_email_update;
pub mod update_email;
pub mod update_handle;
pub mod whoami;


#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct AuthCallback<S: BosStr = DefaultStr> {
    pub access_jwt: S,
    pub did: Did<S>,
    pub handle: S,
    pub refresh_jwt: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for AuthCallback<S> {
    fn nsid() -> &'static str {
        "app.ocho.auth.defs"
    }
    fn def_name() -> &'static str {
        "authCallback"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_ocho_auth_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod auth_callback_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type AccessJwt;
        type Did;
        type Handle;
        type RefreshJwt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type AccessJwt = Unset;
        type Did = Unset;
        type Handle = Unset;
        type RefreshJwt = Unset;
    }
    ///State transition - sets the `access_jwt` field to Set
    pub struct SetAccessJwt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAccessJwt<St> {}
    impl<St: State> State for SetAccessJwt<St> {
        type AccessJwt = Set<members::access_jwt>;
        type Did = St::Did;
        type Handle = St::Handle;
        type RefreshJwt = St::RefreshJwt;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type AccessJwt = St::AccessJwt;
        type Did = Set<members::did>;
        type Handle = St::Handle;
        type RefreshJwt = St::RefreshJwt;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHandle<St> {}
    impl<St: State> State for SetHandle<St> {
        type AccessJwt = St::AccessJwt;
        type Did = St::Did;
        type Handle = Set<members::handle>;
        type RefreshJwt = St::RefreshJwt;
    }
    ///State transition - sets the `refresh_jwt` field to Set
    pub struct SetRefreshJwt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRefreshJwt<St> {}
    impl<St: State> State for SetRefreshJwt<St> {
        type AccessJwt = St::AccessJwt;
        type Did = St::Did;
        type Handle = St::Handle;
        type RefreshJwt = Set<members::refresh_jwt>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `access_jwt` field
        pub struct access_jwt(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `refresh_jwt` field
        pub struct refresh_jwt(());
    }
}

/// Builder for constructing an instance of this type.
pub struct AuthCallbackBuilder<St: auth_callback_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<Did<S>>, Option<S>, Option<S>),
    _type: PhantomData<fn() -> S>,
}

impl AuthCallback<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> AuthCallbackBuilder<auth_callback_state::Empty, DefaultStr> {
        AuthCallbackBuilder::new()
    }
}

impl<S: BosStr> AuthCallback<S> {
    /// Create a new builder for this type
    pub fn builder() -> AuthCallbackBuilder<auth_callback_state::Empty, S> {
        AuthCallbackBuilder::builder()
    }
}

impl AuthCallbackBuilder<auth_callback_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> AuthCallbackBuilder<auth_callback_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AuthCallbackBuilder<St, S>
where
    St: auth_callback_state::State,
    St::AccessJwt: auth_callback_state::IsUnset,
{
    /// Set the `accessJwt` field (required)
    pub fn access_jwt(
        mut self,
        value: impl Into<S>,
    ) -> AuthCallbackBuilder<auth_callback_state::SetAccessJwt<St>, S> {
        self._fields.0 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AuthCallbackBuilder<St, S>
where
    St: auth_callback_state::State,
    St::Did: auth_callback_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> AuthCallbackBuilder<auth_callback_state::SetDid<St>, S> {
        self._fields.1 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AuthCallbackBuilder<St, S>
where
    St: auth_callback_state::State,
    St::Handle: auth_callback_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<S>,
    ) -> AuthCallbackBuilder<auth_callback_state::SetHandle<St>, S> {
        self._fields.2 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AuthCallbackBuilder<St, S>
where
    St: auth_callback_state::State,
    St::RefreshJwt: auth_callback_state::IsUnset,
{
    /// Set the `refreshJwt` field (required)
    pub fn refresh_jwt(
        mut self,
        value: impl Into<S>,
    ) -> AuthCallbackBuilder<auth_callback_state::SetRefreshJwt<St>, S> {
        self._fields.3 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AuthCallbackBuilder<St, S>
where
    St: auth_callback_state::State,
    St::AccessJwt: auth_callback_state::IsSet,
    St::Did: auth_callback_state::IsSet,
    St::Handle: auth_callback_state::IsSet,
    St::RefreshJwt: auth_callback_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> AuthCallback<S> {
        AuthCallback {
            access_jwt: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            handle: self._fields.2.unwrap(),
            refresh_jwt: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> AuthCallback<S> {
        AuthCallback {
            access_jwt: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            handle: self._fields.2.unwrap(),
            refresh_jwt: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_ocho_auth_defs() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("app.ocho.auth.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("authCallback"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("refreshJwt"),
                            SmolStr::new_static("accessJwt"),
                            SmolStr::new_static("handle"), SmolStr::new_static("did")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("accessJwt"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("refreshJwt"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}