jacquard-api 0.12.0-beta.2

Generated AT Protocol API bindings for Jacquard
Documentation
// @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.

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::{BosStr, CowStr, 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::{Deserialize, Serialize};

#[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::{IsSet, IsUnset, Set, Unset};
    #[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 RefreshJwt;
        type Did;
        type Handle;
        type AccessJwt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type RefreshJwt = Unset;
        type Did = Unset;
        type Handle = Unset;
        type AccessJwt = Unset;
    }
    ///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 RefreshJwt = Set<members::refresh_jwt>;
        type Did = St::Did;
        type Handle = St::Handle;
        type AccessJwt = St::AccessJwt;
    }
    ///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 RefreshJwt = St::RefreshJwt;
        type Did = Set<members::did>;
        type Handle = St::Handle;
        type AccessJwt = St::AccessJwt;
    }
    ///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 RefreshJwt = St::RefreshJwt;
        type Did = St::Did;
        type Handle = Set<members::handle>;
        type AccessJwt = St::AccessJwt;
    }
    ///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 RefreshJwt = St::RefreshJwt;
        type Did = St::Did;
        type Handle = St::Handle;
        type AccessJwt = Set<members::access_jwt>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `refresh_jwt` field
        pub struct refresh_jwt(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `access_jwt` field
        pub struct access_jwt(());
    }
}

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

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

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

impl<S: BosStr, St> AuthCallbackBuilder<S, St>
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<S, auth_callback_state::SetAccessJwt<St>> {
        self._fields.0 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AuthCallbackBuilder<S, St>
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<S, auth_callback_state::SetDid<St>> {
        self._fields.1 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AuthCallbackBuilder<S, St>
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<S, auth_callback_state::SetHandle<St>> {
        self._fields.2 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AuthCallbackBuilder<S, St>
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<S, auth_callback_state::SetRefreshJwt<St>> {
        self._fields.3 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AuthCallbackBuilder<S, St>
where
    St: auth_callback_state::State,
    St::RefreshJwt: auth_callback_state::IsSet,
    St::Did: auth_callback_state::IsSet,
    St::Handle: auth_callback_state::IsSet,
    St::AccessJwt: 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> {
    use alloc::collections::BTreeMap;
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    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()
    }
}