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

//! Generated bindings for the `network.slices.waitlist` Lexicon namespace/module.
pub mod invite;
pub mod request;


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

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{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, AtUri, Datetime};
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};
use crate::app_bsky::actor::ProfileViewBasic;
/// An invite granting a DID access with profile information

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct InviteView<S: BosStr = DefaultStr> {
    ///When this invitation was created
    pub created_at: Datetime,
    ///The DID being invited
    pub did: Did<S>,
    ///Optional expiration date for this invitation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<Datetime>,
    ///Profile of the invitee
    #[serde(skip_serializing_if = "Option::is_none")]
    pub profile: Option<ProfileViewBasic<S>>,
    ///The AT URI of the slice this invite is for
    pub slice: AtUri<S>,
    ///The AT URI of this invite record
    #[serde(skip_serializing_if = "Option::is_none")]
    pub uri: Option<AtUri<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A request to join the waitlist with profile information

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct RequestView<S: BosStr = DefaultStr> {
    ///When the user joined the waitlist
    pub created_at: Datetime,
    ///Profile of the requester
    #[serde(skip_serializing_if = "Option::is_none")]
    pub profile: Option<ProfileViewBasic<S>>,
    ///The AT URI of the slice being requested access to
    pub slice: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for InviteView<S> {
    fn nsid() -> &'static str {
        "network.slices.waitlist.defs"
    }
    fn def_name() -> &'static str {
        "inviteView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_slices_waitlist_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for RequestView<S> {
    fn nsid() -> &'static str {
        "network.slices.waitlist.defs"
    }
    fn def_name() -> &'static str {
        "requestView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_slices_waitlist_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod invite_view_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 CreatedAt;
        type Did;
        type Slice;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Did = Unset;
        type Slice = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Did = St::Did;
        type Slice = St::Slice;
    }
    ///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 CreatedAt = St::CreatedAt;
        type Did = Set<members::did>;
        type Slice = St::Slice;
    }
    ///State transition - sets the `slice` field to Set
    pub struct SetSlice<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSlice<St> {}
    impl<St: State> State for SetSlice<St> {
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Slice = Set<members::slice>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `slice` field
        pub struct slice(());
    }
}

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

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

impl<S: BosStr> InviteView<S> {
    /// Create a new builder for this type
    pub fn builder() -> InviteViewBuilder<invite_view_state::Empty, S> {
        InviteViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::CreatedAt: invite_view_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> InviteViewBuilder<invite_view_state::SetCreatedAt<St>, S> {
        self._fields.0 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `expiresAt` field (optional)
    pub fn expires_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `expiresAt` field to an Option value (optional)
    pub fn maybe_expires_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `profile` field (optional)
    pub fn profile(mut self, value: impl Into<Option<ProfileViewBasic<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `profile` field to an Option value (optional)
    pub fn maybe_profile(mut self, value: Option<ProfileViewBasic<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::Slice: invite_view_state::IsUnset,
{
    /// Set the `slice` field (required)
    pub fn slice(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> InviteViewBuilder<invite_view_state::SetSlice<St>, S> {
        self._fields.4 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `uri` field (optional)
    pub fn uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `uri` field to an Option value (optional)
    pub fn maybe_uri(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::CreatedAt: invite_view_state::IsSet,
    St::Did: invite_view_state::IsSet,
    St::Slice: invite_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> InviteView<S> {
        InviteView {
            created_at: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            expires_at: self._fields.2,
            profile: self._fields.3,
            slice: self._fields.4.unwrap(),
            uri: self._fields.5,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> InviteView<S> {
        InviteView {
            created_at: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            expires_at: self._fields.2,
            profile: self._fields.3,
            slice: self._fields.4.unwrap(),
            uri: self._fields.5,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_network_slices_waitlist_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("network.slices.waitlist.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("inviteView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "An invite granting a DID access with profile information",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("did"), SmolStr::new_static("slice"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When this invitation was created"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID being invited"),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("expiresAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Optional expiration date for this invitation",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("profile"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("slice"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The AT URI of the slice this invite is for",
                                    ),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The AT URI of this invite record"),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("requestView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A request to join the waitlist with profile information",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("slice"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the user joined the waitlist"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("profile"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("slice"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The AT URI of the slice being requested access to",
                                    ),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod request_view_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 CreatedAt;
        type Slice;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Slice = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Slice = St::Slice;
    }
    ///State transition - sets the `slice` field to Set
    pub struct SetSlice<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSlice<St> {}
    impl<St: State> State for SetSlice<St> {
        type CreatedAt = St::CreatedAt;
        type Slice = Set<members::slice>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `slice` field
        pub struct slice(());
    }
}

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

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

impl<S: BosStr> RequestView<S> {
    /// Create a new builder for this type
    pub fn builder() -> RequestViewBuilder<request_view_state::Empty, S> {
        RequestViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> RequestViewBuilder<St, S>
where
    St: request_view_state::State,
    St::CreatedAt: request_view_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> RequestViewBuilder<request_view_state::SetCreatedAt<St>, S> {
        self._fields.0 = Option::Some(value.into());
        RequestViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: request_view_state::State, S: BosStr> RequestViewBuilder<St, S> {
    /// Set the `profile` field (optional)
    pub fn profile(mut self, value: impl Into<Option<ProfileViewBasic<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `profile` field to an Option value (optional)
    pub fn maybe_profile(mut self, value: Option<ProfileViewBasic<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> RequestViewBuilder<St, S>
where
    St: request_view_state::State,
    St::Slice: request_view_state::IsUnset,
{
    /// Set the `slice` field (required)
    pub fn slice(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> RequestViewBuilder<request_view_state::SetSlice<St>, S> {
        self._fields.2 = Option::Some(value.into());
        RequestViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RequestViewBuilder<St, S>
where
    St: request_view_state::State,
    St::CreatedAt: request_view_state::IsSet,
    St::Slice: request_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> RequestView<S> {
        RequestView {
            created_at: self._fields.0.unwrap(),
            profile: self._fields.1,
            slice: self._fields.2.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>>,
    ) -> RequestView<S> {
        RequestView {
            created_at: self._fields.0.unwrap(),
            profile: self._fields.1,
            slice: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}