// @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.

pub mod invite;
pub mod request;


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

#[allow(unused_imports)]
use core::marker::PhantomData;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, AtUri, Datetime};
use jacquard_derive::{IntoStatic, lexicon};
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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct InviteView<'a> {
    ///When this invitation was created
    pub created_at: Datetime,
    ///The DID being invited
    #[serde(borrow)]
    pub did: Did<'a>,
    ///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")]
    #[serde(borrow)]
    pub profile: Option<ProfileViewBasic<'a>>,
    ///The AT URI of the slice this invite is for
    #[serde(borrow)]
    pub slice: AtUri<'a>,
    ///The AT URI of this invite record
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub uri: Option<AtUri<'a>>,
}

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RequestView<'a> {
    ///When the user joined the waitlist
    pub created_at: Datetime,
    ///Profile of the requester
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub profile: Option<ProfileViewBasic<'a>>,
    ///The AT URI of the slice being requested access to
    #[serde(borrow)]
    pub slice: AtUri<'a>,
}

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

/// Builder for constructing an instance of this type
pub struct InviteViewBuilder<'a, S: invite_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Datetime>,
        Option<Did<'a>>,
        Option<Datetime>,
        Option<ProfileViewBasic<'a>>,
        Option<AtUri<'a>>,
        Option<AtUri<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, 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<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `profile` field (optional)
    pub fn profile(mut self, value: impl Into<Option<ProfileViewBasic<'a>>>) -> 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<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `uri` field (optional)
    pub fn uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> 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<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S> InviteViewBuilder<'a, S>
where
    S: invite_view_state::State,
    S::Slice: invite_view_state::IsSet,
    S::Did: invite_view_state::IsSet,
    S::CreatedAt: invite_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> InviteView<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> InviteView<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
    impl<S: State> State for SetCreatedAt<S> {
        type CreatedAt = Set<members::created_at>;
        type Slice = S::Slice;
    }
    ///State transition - sets the `slice` field to Set
    pub struct SetSlice<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSlice<S> {}
    impl<S: State> State for SetSlice<S> {
        type CreatedAt = S::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<'a, S: request_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Datetime>, Option<ProfileViewBasic<'a>>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S: request_view_state::State> RequestViewBuilder<'a, S> {
    /// Set the `profile` field (optional)
    pub fn profile(mut self, value: impl Into<Option<ProfileViewBasic<'a>>>) -> 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<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

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