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

pub mod get_latest;
pub mod get_top_artists;
pub mod get_top_releases;
pub mod get_user_top_artists;
pub mod get_user_top_releases;


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

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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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};

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ArtistView<'a> {
    ///MusicBrainz artist ID
    #[serde(borrow)]
    pub mbid: CowStr<'a>,
    ///Artist name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Total number of plays for this artist
    pub play_count: i64,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RecordingView<'a> {
    ///MusicBrainz recording ID
    #[serde(borrow)]
    pub mbid: CowStr<'a>,
    ///Recording/track name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Total number of plays for this recording
    pub play_count: i64,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ReleaseView<'a> {
    ///MusicBrainz release ID
    #[serde(borrow)]
    pub mbid: CowStr<'a>,
    ///Release/album name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Total number of plays for this release
    pub play_count: i64,
}

impl<'a> LexiconSchema for ArtistView<'a> {
    fn nsid() -> &'static str {
        "fm.teal.alpha.stats.defs"
    }
    fn def_name() -> &'static str {
        "artistView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_fm_teal_alpha_stats_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for RecordingView<'a> {
    fn nsid() -> &'static str {
        "fm.teal.alpha.stats.defs"
    }
    fn def_name() -> &'static str {
        "recordingView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_fm_teal_alpha_stats_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ReleaseView<'a> {
    fn nsid() -> &'static str {
        "fm.teal.alpha.stats.defs"
    }
    fn def_name() -> &'static str {
        "releaseView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_fm_teal_alpha_stats_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod artist_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 Mbid;
        type Name;
        type PlayCount;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Mbid = Unset;
        type Name = Unset;
        type PlayCount = Unset;
    }
    ///State transition - sets the `mbid` field to Set
    pub struct SetMbid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMbid<S> {}
    impl<S: State> State for SetMbid<S> {
        type Mbid = Set<members::mbid>;
        type Name = S::Name;
        type PlayCount = S::PlayCount;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type Mbid = S::Mbid;
        type Name = Set<members::name>;
        type PlayCount = S::PlayCount;
    }
    ///State transition - sets the `play_count` field to Set
    pub struct SetPlayCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPlayCount<S> {}
    impl<S: State> State for SetPlayCount<S> {
        type Mbid = S::Mbid;
        type Name = S::Name;
        type PlayCount = Set<members::play_count>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `mbid` field
        pub struct mbid(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `play_count` field
        pub struct play_count(());
    }
}

/// Builder for constructing an instance of this type
pub struct ArtistViewBuilder<'a, S: artist_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ArtistView<'a> {
    /// Create a new builder for this type
    pub fn new() -> ArtistViewBuilder<'a, artist_view_state::Empty> {
        ArtistViewBuilder::new()
    }
}

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

impl<'a, S> ArtistViewBuilder<'a, S>
where
    S: artist_view_state::State,
    S::Mbid: artist_view_state::IsUnset,
{
    /// Set the `mbid` field (required)
    pub fn mbid(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ArtistViewBuilder<'a, artist_view_state::SetMbid<S>> {
        self._fields.0 = Option::Some(value.into());
        ArtistViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ArtistViewBuilder<'a, S>
where
    S: artist_view_state::State,
    S::Name: artist_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ArtistViewBuilder<'a, artist_view_state::SetName<S>> {
        self._fields.1 = Option::Some(value.into());
        ArtistViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ArtistViewBuilder<'a, S>
where
    S: artist_view_state::State,
    S::PlayCount: artist_view_state::IsUnset,
{
    /// Set the `playCount` field (required)
    pub fn play_count(
        mut self,
        value: impl Into<i64>,
    ) -> ArtistViewBuilder<'a, artist_view_state::SetPlayCount<S>> {
        self._fields.2 = Option::Some(value.into());
        ArtistViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ArtistViewBuilder<'a, S>
where
    S: artist_view_state::State,
    S::Mbid: artist_view_state::IsSet,
    S::Name: artist_view_state::IsSet,
    S::PlayCount: artist_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ArtistView<'a> {
        ArtistView {
            mbid: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            play_count: 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>,
        >,
    ) -> ArtistView<'a> {
        ArtistView {
            mbid: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            play_count: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_fm_teal_alpha_stats_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("fm.teal.alpha.stats.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("artistView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("mbid"), SmolStr::new_static("name"),
                            SmolStr::new_static("playCount")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("mbid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("MusicBrainz artist ID"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Artist name")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("playCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("recordingView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("mbid"), SmolStr::new_static("name"),
                            SmolStr::new_static("playCount")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("mbid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("MusicBrainz recording ID"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Recording/track name"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("playCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("releaseView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("mbid"), SmolStr::new_static("name"),
                            SmolStr::new_static("playCount")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("mbid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("MusicBrainz release ID"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Release/album name")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("playCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod recording_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 Mbid;
        type Name;
        type PlayCount;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Mbid = Unset;
        type Name = Unset;
        type PlayCount = Unset;
    }
    ///State transition - sets the `mbid` field to Set
    pub struct SetMbid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMbid<S> {}
    impl<S: State> State for SetMbid<S> {
        type Mbid = Set<members::mbid>;
        type Name = S::Name;
        type PlayCount = S::PlayCount;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type Mbid = S::Mbid;
        type Name = Set<members::name>;
        type PlayCount = S::PlayCount;
    }
    ///State transition - sets the `play_count` field to Set
    pub struct SetPlayCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPlayCount<S> {}
    impl<S: State> State for SetPlayCount<S> {
        type Mbid = S::Mbid;
        type Name = S::Name;
        type PlayCount = Set<members::play_count>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `mbid` field
        pub struct mbid(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `play_count` field
        pub struct play_count(());
    }
}

/// Builder for constructing an instance of this type
pub struct RecordingViewBuilder<'a, S: recording_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> RecordingView<'a> {
    /// Create a new builder for this type
    pub fn new() -> RecordingViewBuilder<'a, recording_view_state::Empty> {
        RecordingViewBuilder::new()
    }
}

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

impl<'a, S> RecordingViewBuilder<'a, S>
where
    S: recording_view_state::State,
    S::Mbid: recording_view_state::IsUnset,
{
    /// Set the `mbid` field (required)
    pub fn mbid(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> RecordingViewBuilder<'a, recording_view_state::SetMbid<S>> {
        self._fields.0 = Option::Some(value.into());
        RecordingViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RecordingViewBuilder<'a, S>
where
    S: recording_view_state::State,
    S::Name: recording_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> RecordingViewBuilder<'a, recording_view_state::SetName<S>> {
        self._fields.1 = Option::Some(value.into());
        RecordingViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RecordingViewBuilder<'a, S>
where
    S: recording_view_state::State,
    S::PlayCount: recording_view_state::IsUnset,
{
    /// Set the `playCount` field (required)
    pub fn play_count(
        mut self,
        value: impl Into<i64>,
    ) -> RecordingViewBuilder<'a, recording_view_state::SetPlayCount<S>> {
        self._fields.2 = Option::Some(value.into());
        RecordingViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RecordingViewBuilder<'a, S>
where
    S: recording_view_state::State,
    S::Mbid: recording_view_state::IsSet,
    S::Name: recording_view_state::IsSet,
    S::PlayCount: recording_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> RecordingView<'a> {
        RecordingView {
            mbid: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            play_count: 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>,
        >,
    ) -> RecordingView<'a> {
        RecordingView {
            mbid: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            play_count: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod release_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 PlayCount;
        type Mbid;
        type Name;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type PlayCount = Unset;
        type Mbid = Unset;
        type Name = Unset;
    }
    ///State transition - sets the `play_count` field to Set
    pub struct SetPlayCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPlayCount<S> {}
    impl<S: State> State for SetPlayCount<S> {
        type PlayCount = Set<members::play_count>;
        type Mbid = S::Mbid;
        type Name = S::Name;
    }
    ///State transition - sets the `mbid` field to Set
    pub struct SetMbid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMbid<S> {}
    impl<S: State> State for SetMbid<S> {
        type PlayCount = S::PlayCount;
        type Mbid = Set<members::mbid>;
        type Name = S::Name;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type PlayCount = S::PlayCount;
        type Mbid = S::Mbid;
        type Name = Set<members::name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `play_count` field
        pub struct play_count(());
        ///Marker type for the `mbid` field
        pub struct mbid(());
        ///Marker type for the `name` field
        pub struct name(());
    }
}

/// Builder for constructing an instance of this type
pub struct ReleaseViewBuilder<'a, S: release_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ReleaseView<'a> {
    /// Create a new builder for this type
    pub fn new() -> ReleaseViewBuilder<'a, release_view_state::Empty> {
        ReleaseViewBuilder::new()
    }
}

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

impl<'a, S> ReleaseViewBuilder<'a, S>
where
    S: release_view_state::State,
    S::Mbid: release_view_state::IsUnset,
{
    /// Set the `mbid` field (required)
    pub fn mbid(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ReleaseViewBuilder<'a, release_view_state::SetMbid<S>> {
        self._fields.0 = Option::Some(value.into());
        ReleaseViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ReleaseViewBuilder<'a, S>
where
    S: release_view_state::State,
    S::Name: release_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ReleaseViewBuilder<'a, release_view_state::SetName<S>> {
        self._fields.1 = Option::Some(value.into());
        ReleaseViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ReleaseViewBuilder<'a, S>
where
    S: release_view_state::State,
    S::PlayCount: release_view_state::IsUnset,
{
    /// Set the `playCount` field (required)
    pub fn play_count(
        mut self,
        value: impl Into<i64>,
    ) -> ReleaseViewBuilder<'a, release_view_state::SetPlayCount<S>> {
        self._fields.2 = Option::Some(value.into());
        ReleaseViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ReleaseViewBuilder<'a, S>
where
    S: release_view_state::State,
    S::PlayCount: release_view_state::IsSet,
    S::Mbid: release_view_state::IsSet,
    S::Name: release_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ReleaseView<'a> {
        ReleaseView {
            mbid: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            play_count: 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>,
        >,
    ) -> ReleaseView<'a> {
        ReleaseView {
            mbid: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            play_count: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}