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

#[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_common::types::string::AtUri;
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::games_gamesgamesgamesgames::search_slugs;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SearchSlugs<'a> {
    ///Defaults to `10`. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    #[serde(borrow)]
    pub slug: CowStr<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SearchSlugsOutput<'a> {
    #[serde(borrow)]
    pub slugs: Vec<search_slugs::SlugResult<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SlugResult<'a> {
    #[serde(borrow)]
    pub r#ref: AtUri<'a>,
    #[serde(borrow)]
    pub slug: CowStr<'a>,
}

/// Response type for games.gamesgamesgamesgames.searchSlugs
pub struct SearchSlugsResponse;
impl jacquard_common::xrpc::XrpcResp for SearchSlugsResponse {
    const NSID: &'static str = "games.gamesgamesgamesgames.searchSlugs";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = SearchSlugsOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for SearchSlugs<'a> {
    const NSID: &'static str = "games.gamesgamesgamesgames.searchSlugs";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = SearchSlugsResponse;
}

/// Endpoint type for games.gamesgamesgamesgames.searchSlugs
pub struct SearchSlugsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for SearchSlugsRequest {
    const PATH: &'static str = "/xrpc/games.gamesgamesgamesgames.searchSlugs";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = SearchSlugs<'de>;
    type Response = SearchSlugsResponse;
}

impl<'a> LexiconSchema for SlugResult<'a> {
    fn nsid() -> &'static str {
        "games.gamesgamesgamesgames.searchSlugs"
    }
    fn def_name() -> &'static str {
        "slugResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_games_gamesgamesgamesgames_searchSlugs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn _default_limit() -> Option<i64> {
    Some(10i64)
}

pub mod search_slugs_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 Slug;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Slug = Unset;
    }
    ///State transition - sets the `slug` field to Set
    pub struct SetSlug<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSlug<S> {}
    impl<S: State> State for SetSlug<S> {
        type Slug = Set<members::slug>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `slug` field
        pub struct slug(());
    }
}

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

impl<'a> SearchSlugs<'a> {
    /// Create a new builder for this type
    pub fn new() -> SearchSlugsBuilder<'a, search_slugs_state::Empty> {
        SearchSlugsBuilder::new()
    }
}

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

impl<'a, S: search_slugs_state::State> SearchSlugsBuilder<'a, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S> SearchSlugsBuilder<'a, S>
where
    S: search_slugs_state::State,
    S::Slug: search_slugs_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SearchSlugs<'a> {
        SearchSlugs {
            limit: self._fields.0,
            slug: self._fields.1.unwrap(),
        }
    }
}

pub mod slug_result_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 Slug;
        type Ref;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Slug = Unset;
        type Ref = Unset;
    }
    ///State transition - sets the `slug` field to Set
    pub struct SetSlug<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSlug<S> {}
    impl<S: State> State for SetSlug<S> {
        type Slug = Set<members::slug>;
        type Ref = S::Ref;
    }
    ///State transition - sets the `ref` field to Set
    pub struct SetRef<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRef<S> {}
    impl<S: State> State for SetRef<S> {
        type Slug = S::Slug;
        type Ref = Set<members::r#ref>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `slug` field
        pub struct slug(());
        ///Marker type for the `ref` field
        pub struct r#ref(());
    }
}

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

impl<'a> SlugResult<'a> {
    /// Create a new builder for this type
    pub fn new() -> SlugResultBuilder<'a, slug_result_state::Empty> {
        SlugResultBuilder::new()
    }
}

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

impl<'a, S> SlugResultBuilder<'a, S>
where
    S: slug_result_state::State,
    S::Ref: slug_result_state::IsUnset,
{
    /// Set the `ref` field (required)
    pub fn r#ref(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> SlugResultBuilder<'a, slug_result_state::SetRef<S>> {
        self._fields.0 = Option::Some(value.into());
        SlugResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S> SlugResultBuilder<'a, S>
where
    S: slug_result_state::State,
    S::Slug: slug_result_state::IsSet,
    S::Ref: slug_result_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SlugResult<'a> {
        SlugResult {
            r#ref: self._fields.0.unwrap(),
            slug: self._fields.1.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>,
        >,
    ) -> SlugResult<'a> {
        SlugResult {
            r#ref: self._fields.0.unwrap(),
            slug: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_games_gamesgamesgamesgames_searchSlugs() -> 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("games.gamesgamesgamesgames.searchSlugs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("slug")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("limit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("slug"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static("The slug value to search for."),
                                        ),
                                        min_length: Some(1usize),
                                        max_length: Some(64usize),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("slugResult"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("slug"), SmolStr::new_static("ref")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("ref"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("slug"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}