// @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, 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::AtUri;
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::games_gamesgamesgamesgames::search_slugs;

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


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SearchSlugsOutput<S: BosStr = DefaultStr> {
    pub slugs: Vec<search_slugs::SlugResult<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SlugResult<S: BosStr = DefaultStr> {
    pub r#ref: AtUri<S>,
    pub slug: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/** Response marker for the `games.gamesgamesgamesgames.searchSlugs` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `SearchSlugsOutput<S>` for this endpoint.*/
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<S: BosStr> = SearchSlugsOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

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

/** Endpoint marker for the `games.gamesgamesgamesgames.searchSlugs` query.

Path: `/xrpc/games.gamesgamesgamesgames.searchSlugs`. The request payload type is `SearchSlugs<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
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<S: BosStr> = SearchSlugs<S>;
    type Response = SearchSlugsResponse;
}

impl<S: BosStr> LexiconSchema for SlugResult<S> {
    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<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSlug<St> {}
    impl<St: State> State for SetSlug<St> {
        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<St: search_slugs_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<i64>, Option<S>),
    _type: PhantomData<fn() -> S>,
}

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

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

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

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

impl<St: search_slugs_state::State, S: BosStr> SearchSlugsBuilder<St, 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<St, S: BosStr> SearchSlugsBuilder<St, S>
where
    St: search_slugs_state::State,
    St::Slug: search_slugs_state::IsUnset,
{
    /// Set the `slug` field (required)
    pub fn slug(
        mut self,
        value: impl Into<S>,
    ) -> SearchSlugsBuilder<search_slugs_state::SetSlug<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SearchSlugsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

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

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

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

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

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

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

impl<St, S: BosStr> SlugResultBuilder<St, S>
where
    St: slug_result_state::State,
    St::Ref: slug_result_state::IsSet,
    St::Slug: slug_result_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SlugResult<S> {
        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<SmolStr, Data<S>>,
    ) -> SlugResult<S> {
        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()
    }
}