// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.firehose.barklesheep.placeSheeps
//
// 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_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_firehose::barklesheep::place_sheeps;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PlaceSheeps<'a> {
    #[serde(borrow)]
    pub game_id: CowStr<'a>,
    #[serde(borrow)]
    pub sheeps: Vec<place_sheeps::SheepPlacement<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct PlaceSheepsOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub success: Option<bool>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SheepPlacement<'a> {
    pub horizontal: bool,
    pub start: i64,
    #[serde(borrow)]
    pub r#type: CowStr<'a>,
}

/// Response type for games.firehose.barklesheep.placeSheeps
pub struct PlaceSheepsResponse;
impl jacquard_common::xrpc::XrpcResp for PlaceSheepsResponse {
    const NSID: &'static str = "games.firehose.barklesheep.placeSheeps";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = PlaceSheepsOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for PlaceSheeps<'a> {
    const NSID: &'static str = "games.firehose.barklesheep.placeSheeps";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = PlaceSheepsResponse;
}

/// Endpoint type for games.firehose.barklesheep.placeSheeps
pub struct PlaceSheepsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for PlaceSheepsRequest {
    const PATH: &'static str = "/xrpc/games.firehose.barklesheep.placeSheeps";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = PlaceSheeps<'de>;
    type Response = PlaceSheepsResponse;
}

impl<'a> LexiconSchema for SheepPlacement<'a> {
    fn nsid() -> &'static str {
        "games.firehose.barklesheep.placeSheeps"
    }
    fn def_name() -> &'static str {
        "sheepPlacement"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_games_firehose_barklesheep_placeSheeps()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

impl<'a> PlaceSheeps<'a> {
    /// Create a new builder for this type
    pub fn new() -> PlaceSheepsBuilder<'a, place_sheeps_state::Empty> {
        PlaceSheepsBuilder::new()
    }
}

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

impl<'a, S> PlaceSheepsBuilder<'a, S>
where
    S: place_sheeps_state::State,
    S::GameId: place_sheeps_state::IsUnset,
{
    /// Set the `gameId` field (required)
    pub fn game_id(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> PlaceSheepsBuilder<'a, place_sheeps_state::SetGameId<S>> {
        self._fields.0 = Option::Some(value.into());
        PlaceSheepsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> PlaceSheepsBuilder<'a, S>
where
    S: place_sheeps_state::State,
    S::Sheeps: place_sheeps_state::IsUnset,
{
    /// Set the `sheeps` field (required)
    pub fn sheeps(
        mut self,
        value: impl Into<Vec<place_sheeps::SheepPlacement<'a>>>,
    ) -> PlaceSheepsBuilder<'a, place_sheeps_state::SetSheeps<S>> {
        self._fields.1 = Option::Some(value.into());
        PlaceSheepsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> PlaceSheepsBuilder<'a, S>
where
    S: place_sheeps_state::State,
    S::GameId: place_sheeps_state::IsSet,
    S::Sheeps: place_sheeps_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> PlaceSheeps<'a> {
        PlaceSheeps {
            game_id: self._fields.0.unwrap(),
            sheeps: 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>,
        >,
    ) -> PlaceSheeps<'a> {
        PlaceSheeps {
            game_id: self._fields.0.unwrap(),
            sheeps: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod sheep_placement_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 Start;
        type Horizontal;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Start = Unset;
        type Horizontal = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `start` field to Set
    pub struct SetStart<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStart<S> {}
    impl<S: State> State for SetStart<S> {
        type Start = Set<members::start>;
        type Horizontal = S::Horizontal;
        type Type = S::Type;
    }
    ///State transition - sets the `horizontal` field to Set
    pub struct SetHorizontal<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHorizontal<S> {}
    impl<S: State> State for SetHorizontal<S> {
        type Start = S::Start;
        type Horizontal = Set<members::horizontal>;
        type Type = S::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetType<S> {}
    impl<S: State> State for SetType<S> {
        type Start = S::Start;
        type Horizontal = S::Horizontal;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `start` field
        pub struct start(());
        ///Marker type for the `horizontal` field
        pub struct horizontal(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

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

impl<'a> SheepPlacement<'a> {
    /// Create a new builder for this type
    pub fn new() -> SheepPlacementBuilder<'a, sheep_placement_state::Empty> {
        SheepPlacementBuilder::new()
    }
}

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

impl<'a, S> SheepPlacementBuilder<'a, S>
where
    S: sheep_placement_state::State,
    S::Horizontal: sheep_placement_state::IsUnset,
{
    /// Set the `horizontal` field (required)
    pub fn horizontal(
        mut self,
        value: impl Into<bool>,
    ) -> SheepPlacementBuilder<'a, sheep_placement_state::SetHorizontal<S>> {
        self._fields.0 = Option::Some(value.into());
        SheepPlacementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SheepPlacementBuilder<'a, S>
where
    S: sheep_placement_state::State,
    S::Start: sheep_placement_state::IsUnset,
{
    /// Set the `start` field (required)
    pub fn start(
        mut self,
        value: impl Into<i64>,
    ) -> SheepPlacementBuilder<'a, sheep_placement_state::SetStart<S>> {
        self._fields.1 = Option::Some(value.into());
        SheepPlacementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SheepPlacementBuilder<'a, S>
where
    S: sheep_placement_state::State,
    S::Type: sheep_placement_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SheepPlacementBuilder<'a, sheep_placement_state::SetType<S>> {
        self._fields.2 = Option::Some(value.into());
        SheepPlacementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SheepPlacementBuilder<'a, S>
where
    S: sheep_placement_state::State,
    S::Start: sheep_placement_state::IsSet,
    S::Horizontal: sheep_placement_state::IsSet,
    S::Type: sheep_placement_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SheepPlacement<'a> {
        SheepPlacement {
            horizontal: self._fields.0.unwrap(),
            start: self._fields.1.unwrap(),
            r#type: 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>,
        >,
    ) -> SheepPlacement<'a> {
        SheepPlacement {
            horizontal: self._fields.0.unwrap(),
            start: self._fields.1.unwrap(),
            r#type: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_games_firehose_barklesheep_placeSheeps() -> 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.firehose.barklesheep.placeSheeps"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcProcedure(LexXrpcProcedure {
                    input: Some(LexXrpcBody {
                        encoding: CowStr::new_static("application/json"),
                        schema: Some(
                            LexXrpcBodySchema::Object(LexObject {
                                required: Some(
                                    vec![
                                        SmolStr::new_static("gameId"), SmolStr::new_static("sheeps")
                                    ],
                                ),
                                properties: {
                                    #[allow(unused_mut)]
                                    let mut map = BTreeMap::new();
                                    map.insert(
                                        SmolStr::new_static("gameId"),
                                        LexObjectProperty::String(LexString {
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("sheeps"),
                                        LexObjectProperty::Array(LexArray {
                                            items: LexArrayItem::Ref(LexRef {
                                                r#ref: CowStr::new_static("#sheepPlacement"),
                                                ..Default::default()
                                            }),
                                            ..Default::default()
                                        }),
                                    );
                                    map
                                },
                                ..Default::default()
                            }),
                        ),
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sheepPlacement"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("type"), SmolStr::new_static("start"),
                            SmolStr::new_static("horizontal")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("horizontal"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("start"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}