// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: social.arabica.alpha.recipe
//
// 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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
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::social_arabica::alpha::recipe;
/// A reusable brewing recipe with parameters for repeatable coffee preparation

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "social.arabica.alpha.recipe",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Recipe<S: BosStr = DefaultStr> {
    ///AT-URI reference to a specific brewer record
    #[serde(skip_serializing_if = "Option::is_none")]
    pub brewer_ref: Option<AtUri<S>>,
    ///Fallback brewer type when no specific brewer is referenced (e.g., 'Pour-Over', 'French Press')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub brewer_type: Option<S>,
    ///Amount of coffee in tenths of grams (e.g., 180 = 18.0g)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coffee_amount: Option<i64>,
    ///Timestamp when the recipe was created
    pub created_at: Datetime,
    ///User-given name for the recipe (e.g., 'James Hoffmann V60')
    pub name: S,
    ///Free-text instructions, tips, or notes about the recipe
    #[serde(skip_serializing_if = "Option::is_none")]
    pub notes: Option<S>,
    ///Array of pour information for multi-pour methods
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pours: Option<Vec<recipe::Pour<S>>>,
    ///AT-URI of the recipe this was forked/copied from
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_ref: Option<AtUri<S>>,
    ///Amount of water in tenths of grams (e.g., 3000 = 300.0g)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub water_amount: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RecipeGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Recipe<S>,
}

/// Information about a single pour in a multi-pour brewing method

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Pour<S: BosStr = DefaultStr> {
    ///Time of this pour relative to brew start (seconds)
    pub time_seconds: i64,
    ///Amount of water in this pour (grams or ml)
    pub water_amount: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> Recipe<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, RecipeRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct RecipeRecord;
impl XrpcResp for RecipeRecord {
    const NSID: &'static str = "social.arabica.alpha.recipe";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = RecipeGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<RecipeGetRecordOutput<S>> for Recipe<S> {
    fn from(output: RecipeGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Recipe<S> {
    const NSID: &'static str = "social.arabica.alpha.recipe";
    type Record = RecipeRecord;
}

impl Collection for RecipeRecord {
    const NSID: &'static str = "social.arabica.alpha.recipe";
    type Record = RecipeRecord;
}

impl<S: BosStr> LexiconSchema for Recipe<S> {
    fn nsid() -> &'static str {
        "social.arabica.alpha.recipe"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_arabica_alpha_recipe()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.brewer_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("brewer_type"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.coffee_amount {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("coffee_amount"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.notes {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("notes"),
                    max: 2000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.water_amount {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("water_amount"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Pour<S> {
    fn nsid() -> &'static str {
        "social.arabica.alpha.recipe"
    }
    fn def_name() -> &'static str {
        "pour"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_arabica_alpha_recipe()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.time_seconds;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("time_seconds"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.water_amount;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("water_amount"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod recipe_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 Name;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Name = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Name = St::Name;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type CreatedAt = St::CreatedAt;
        type Name = Set<members::name>;
    }
    /// 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 `name` field
        pub struct name(());
    }
}

/// Builder for constructing an instance of this type.
pub struct RecipeBuilder<St: recipe_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<AtUri<S>>,
        Option<S>,
        Option<i64>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<Vec<recipe::Pour<S>>>,
        Option<AtUri<S>>,
        Option<i64>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Recipe<S> {
    /// Create a new builder for this type
    pub fn builder() -> RecipeBuilder<recipe_state::Empty, S> {
        RecipeBuilder::builder()
    }
}

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

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

impl<St: recipe_state::State, S: BosStr> RecipeBuilder<St, S> {
    /// Set the `brewerRef` field (optional)
    pub fn brewer_ref(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `brewerRef` field to an Option value (optional)
    pub fn maybe_brewer_ref(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: recipe_state::State, S: BosStr> RecipeBuilder<St, S> {
    /// Set the `brewerType` field (optional)
    pub fn brewer_type(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `brewerType` field to an Option value (optional)
    pub fn maybe_brewer_type(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: recipe_state::State, S: BosStr> RecipeBuilder<St, S> {
    /// Set the `coffeeAmount` field (optional)
    pub fn coffee_amount(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `coffeeAmount` field to an Option value (optional)
    pub fn maybe_coffee_amount(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> RecipeBuilder<St, S>
where
    St: recipe_state::State,
    St::CreatedAt: recipe_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> RecipeBuilder<recipe_state::SetCreatedAt<St>, S> {
        self._fields.3 = Option::Some(value.into());
        RecipeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RecipeBuilder<St, S>
where
    St: recipe_state::State,
    St::Name: recipe_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> RecipeBuilder<recipe_state::SetName<St>, S> {
        self._fields.4 = Option::Some(value.into());
        RecipeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: recipe_state::State, S: BosStr> RecipeBuilder<St, S> {
    /// Set the `notes` field (optional)
    pub fn notes(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `notes` field to an Option value (optional)
    pub fn maybe_notes(mut self, value: Option<S>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: recipe_state::State, S: BosStr> RecipeBuilder<St, S> {
    /// Set the `pours` field (optional)
    pub fn pours(mut self, value: impl Into<Option<Vec<recipe::Pour<S>>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `pours` field to an Option value (optional)
    pub fn maybe_pours(mut self, value: Option<Vec<recipe::Pour<S>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: recipe_state::State, S: BosStr> RecipeBuilder<St, S> {
    /// Set the `sourceRef` field (optional)
    pub fn source_ref(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `sourceRef` field to an Option value (optional)
    pub fn maybe_source_ref(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: recipe_state::State, S: BosStr> RecipeBuilder<St, S> {
    /// Set the `waterAmount` field (optional)
    pub fn water_amount(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `waterAmount` field to an Option value (optional)
    pub fn maybe_water_amount(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St, S: BosStr> RecipeBuilder<St, S>
where
    St: recipe_state::State,
    St::CreatedAt: recipe_state::IsSet,
    St::Name: recipe_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Recipe<S> {
        Recipe {
            brewer_ref: self._fields.0,
            brewer_type: self._fields.1,
            coffee_amount: self._fields.2,
            created_at: self._fields.3.unwrap(),
            name: self._fields.4.unwrap(),
            notes: self._fields.5,
            pours: self._fields.6,
            source_ref: self._fields.7,
            water_amount: self._fields.8,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Recipe<S> {
        Recipe {
            brewer_ref: self._fields.0,
            brewer_type: self._fields.1,
            coffee_amount: self._fields.2,
            created_at: self._fields.3.unwrap(),
            name: self._fields.4.unwrap(),
            notes: self._fields.5,
            pours: self._fields.6,
            source_ref: self._fields.7,
            water_amount: self._fields.8,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_social_arabica_alpha_recipe() -> 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("social.arabica.alpha.recipe"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A reusable brewing recipe with parameters for repeatable coffee preparation",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("name"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("brewerRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI reference to a specific brewer record",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("brewerType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Fallback brewer type when no specific brewer is referenced (e.g., 'Pour-Over', 'French Press')",
                                        ),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("coffeeAmount"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Timestamp when the recipe was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "User-given name for the recipe (e.g., 'James Hoffmann V60')",
                                        ),
                                    ),
                                    max_length: Some(200usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("notes"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Free-text instructions, tips, or notes about the recipe",
                                        ),
                                    ),
                                    max_length: Some(2000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("pours"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Array of pour information for multi-pour methods",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#pour"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sourceRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI of the recipe this was forked/copied from",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("waterAmount"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pour"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Information about a single pour in a multi-pour brewing method",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("waterAmount"),
                            SmolStr::new_static("timeSeconds")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("timeSeconds"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("waterAmount"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod pour_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 TimeSeconds;
        type WaterAmount;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type TimeSeconds = Unset;
        type WaterAmount = Unset;
    }
    ///State transition - sets the `time_seconds` field to Set
    pub struct SetTimeSeconds<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTimeSeconds<St> {}
    impl<St: State> State for SetTimeSeconds<St> {
        type TimeSeconds = Set<members::time_seconds>;
        type WaterAmount = St::WaterAmount;
    }
    ///State transition - sets the `water_amount` field to Set
    pub struct SetWaterAmount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetWaterAmount<St> {}
    impl<St: State> State for SetWaterAmount<St> {
        type TimeSeconds = St::TimeSeconds;
        type WaterAmount = Set<members::water_amount>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `time_seconds` field
        pub struct time_seconds(());
        ///Marker type for the `water_amount` field
        pub struct water_amount(());
    }
}

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

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

impl<S: BosStr> Pour<S> {
    /// Create a new builder for this type
    pub fn builder() -> PourBuilder<pour_state::Empty, S> {
        PourBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> PourBuilder<St, S>
where
    St: pour_state::State,
    St::TimeSeconds: pour_state::IsUnset,
{
    /// Set the `timeSeconds` field (required)
    pub fn time_seconds(
        mut self,
        value: impl Into<i64>,
    ) -> PourBuilder<pour_state::SetTimeSeconds<St>, S> {
        self._fields.0 = Option::Some(value.into());
        PourBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PourBuilder<St, S>
where
    St: pour_state::State,
    St::WaterAmount: pour_state::IsUnset,
{
    /// Set the `waterAmount` field (required)
    pub fn water_amount(
        mut self,
        value: impl Into<i64>,
    ) -> PourBuilder<pour_state::SetWaterAmount<St>, S> {
        self._fields.1 = Option::Some(value.into());
        PourBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PourBuilder<St, S>
where
    St: pour_state::State,
    St::TimeSeconds: pour_state::IsSet,
    St::WaterAmount: pour_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Pour<S> {
        Pour {
            time_seconds: self._fields.0.unwrap(),
            water_amount: 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>>) -> Pour<S> {
        Pour {
            time_seconds: self._fields.0.unwrap(),
            water_amount: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}