// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: club.stellz.evm.addressControl
//
// 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};
use jacquard_common::deps::bytes::Bytes;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Datetime, UriValue};
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::club_stellz::evm::address_control;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct AddressControl<S: BosStr = DefaultStr> {
    ///Ethereum address as bytes (20 bytes)
    #[serde(with = "jacquard_common::serde_bytes_helper")]
    pub address: Bytes,
    ///List of all Chain IDs (besides the one in the sign-in message, though you can include it) that the holder of this address is also active on & accepts tokens thru.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub also_on: Option<Vec<i64>>,
    ///Sign in With Ethereum message signature as bytes
    #[serde(with = "jacquard_common::serde_bytes_helper")]
    pub signature: Bytes,
    pub siwe: address_control::SiweMessage<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 SiweMessage<S: BosStr = DefaultStr> {
    ///Ethereum address in 0x-prefixed, checksummed hex format
    pub address: S,
    ///Chain ID of the Ethereum VM network the address is on
    pub chain_id: i64,
    ///Domain of the application requesting the signature, e.g. 'wallet-link.stellz.club'
    pub domain: S,
    ///Timestamp when the message was signed
    pub issued_at: Datetime,
    ///Random nonce the message was signed with
    pub nonce: S,
    ///The message shown to the user in their wallet before signing, which MUST be of the format 'Prove control of ${address} to link it to ${did}', where ${address} is the linked Ethereum address in 0x-prefixed, checksummed hex format, and ${did} is the DID of the user.
    pub statement: S,
    ///URI of the application requesting the signature, e.g. 'https://wallet-link.stellz.club'
    pub uri: UriValue<S>,
    ///Sign in With Ethereum message version
    pub version: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for AddressControl<S> {
    fn nsid() -> &'static str {
        "club.stellz.evm.addressControl"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_club_stellz_evm_addressControl()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SiweMessage<S> {
    fn nsid() -> &'static str {
        "club.stellz.evm.addressControl"
    }
    fn def_name() -> &'static str {
        "siweMessage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_club_stellz_evm_addressControl()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.address;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 42usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("address"),
                    max: 42usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.address;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 42usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("address"),
                    min: 42usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.nonce;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("nonce"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.nonce;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 8usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("nonce"),
                    min: 8usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.statement;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 78usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("statement"),
                    min: 78usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

pub mod address_control_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 Address;
        type Signature;
        type Siwe;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Address = Unset;
        type Signature = Unset;
        type Siwe = Unset;
    }
    ///State transition - sets the `address` field to Set
    pub struct SetAddress<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAddress<St> {}
    impl<St: State> State for SetAddress<St> {
        type Address = Set<members::address>;
        type Signature = St::Signature;
        type Siwe = St::Siwe;
    }
    ///State transition - sets the `signature` field to Set
    pub struct SetSignature<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSignature<St> {}
    impl<St: State> State for SetSignature<St> {
        type Address = St::Address;
        type Signature = Set<members::signature>;
        type Siwe = St::Siwe;
    }
    ///State transition - sets the `siwe` field to Set
    pub struct SetSiwe<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSiwe<St> {}
    impl<St: State> State for SetSiwe<St> {
        type Address = St::Address;
        type Signature = St::Signature;
        type Siwe = Set<members::siwe>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `address` field
        pub struct address(());
        ///Marker type for the `signature` field
        pub struct signature(());
        ///Marker type for the `siwe` field
        pub struct siwe(());
    }
}

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

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

impl<S: BosStr> AddressControl<S> {
    /// Create a new builder for this type
    pub fn builder() -> AddressControlBuilder<address_control_state::Empty, S> {
        AddressControlBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> AddressControlBuilder<St, S>
where
    St: address_control_state::State,
    St::Address: address_control_state::IsUnset,
{
    /// Set the `address` field (required)
    pub fn address(
        mut self,
        value: impl Into<Bytes>,
    ) -> AddressControlBuilder<address_control_state::SetAddress<St>, S> {
        self._fields.0 = Option::Some(value.into());
        AddressControlBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: address_control_state::State, S: BosStr> AddressControlBuilder<St, S> {
    /// Set the `alsoOn` field (optional)
    pub fn also_on(mut self, value: impl Into<Option<Vec<i64>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `alsoOn` field to an Option value (optional)
    pub fn maybe_also_on(mut self, value: Option<Vec<i64>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> AddressControlBuilder<St, S>
where
    St: address_control_state::State,
    St::Signature: address_control_state::IsUnset,
{
    /// Set the `signature` field (required)
    pub fn signature(
        mut self,
        value: impl Into<Bytes>,
    ) -> AddressControlBuilder<address_control_state::SetSignature<St>, S> {
        self._fields.2 = Option::Some(value.into());
        AddressControlBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AddressControlBuilder<St, S>
where
    St: address_control_state::State,
    St::Siwe: address_control_state::IsUnset,
{
    /// Set the `siwe` field (required)
    pub fn siwe(
        mut self,
        value: impl Into<address_control::SiweMessage<S>>,
    ) -> AddressControlBuilder<address_control_state::SetSiwe<St>, S> {
        self._fields.3 = Option::Some(value.into());
        AddressControlBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AddressControlBuilder<St, S>
where
    St: address_control_state::State,
    St::Address: address_control_state::IsSet,
    St::Signature: address_control_state::IsSet,
    St::Siwe: address_control_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> AddressControl<S> {
        AddressControl {
            address: self._fields.0.unwrap(),
            also_on: self._fields.1,
            signature: self._fields.2.unwrap(),
            siwe: self._fields.3.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>>,
    ) -> AddressControl<S> {
        AddressControl {
            address: self._fields.0.unwrap(),
            also_on: self._fields.1,
            signature: self._fields.2.unwrap(),
            siwe: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_club_stellz_evm_addressControl() -> 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("club.stellz.evm.addressControl"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("address"),
                            SmolStr::new_static("signature"), SmolStr::new_static("siwe")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("address"),
                            LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("alsoOn"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "List of all Chain IDs (besides the one in the sign-in message, though you can include it) that the holder of this address is also active on & accepts tokens thru.",
                                    ),
                                ),
                                items: LexArrayItem::Integer(LexInteger {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("signature"),
                            LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("siwe"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#siweMessage"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("siweMessage"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("domain"),
                            SmolStr::new_static("address"),
                            SmolStr::new_static("statement"), SmolStr::new_static("uri"),
                            SmolStr::new_static("version"),
                            SmolStr::new_static("chainId"), SmolStr::new_static("nonce"),
                            SmolStr::new_static("issuedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("address"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Ethereum address in 0x-prefixed, checksummed hex format",
                                    ),
                                ),
                                min_length: Some(42usize),
                                max_length: Some(42usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("chainId"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("domain"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Domain of the application requesting the signature, e.g. 'wallet-link.stellz.club'",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("issuedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Timestamp when the message was signed"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("nonce"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Random nonce the message was signed with",
                                    ),
                                ),
                                min_length: Some(8usize),
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("statement"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The message shown to the user in their wallet before signing, which MUST be of the format 'Prove control of ${address} to link it to ${did}', where ${address} is the linked Ethereum address in 0x-prefixed, checksummed hex format, and ${did} is the DID of the user.",
                                    ),
                                ),
                                min_length: Some(78usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "URI of the application requesting the signature, e.g. 'https://wallet-link.stellz.club'",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("version"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Sign in With Ethereum message version"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod siwe_message_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 Address;
        type ChainId;
        type Domain;
        type IssuedAt;
        type Nonce;
        type Statement;
        type Uri;
        type Version;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Address = Unset;
        type ChainId = Unset;
        type Domain = Unset;
        type IssuedAt = Unset;
        type Nonce = Unset;
        type Statement = Unset;
        type Uri = Unset;
        type Version = Unset;
    }
    ///State transition - sets the `address` field to Set
    pub struct SetAddress<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAddress<St> {}
    impl<St: State> State for SetAddress<St> {
        type Address = Set<members::address>;
        type ChainId = St::ChainId;
        type Domain = St::Domain;
        type IssuedAt = St::IssuedAt;
        type Nonce = St::Nonce;
        type Statement = St::Statement;
        type Uri = St::Uri;
        type Version = St::Version;
    }
    ///State transition - sets the `chain_id` field to Set
    pub struct SetChainId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetChainId<St> {}
    impl<St: State> State for SetChainId<St> {
        type Address = St::Address;
        type ChainId = Set<members::chain_id>;
        type Domain = St::Domain;
        type IssuedAt = St::IssuedAt;
        type Nonce = St::Nonce;
        type Statement = St::Statement;
        type Uri = St::Uri;
        type Version = St::Version;
    }
    ///State transition - sets the `domain` field to Set
    pub struct SetDomain<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDomain<St> {}
    impl<St: State> State for SetDomain<St> {
        type Address = St::Address;
        type ChainId = St::ChainId;
        type Domain = Set<members::domain>;
        type IssuedAt = St::IssuedAt;
        type Nonce = St::Nonce;
        type Statement = St::Statement;
        type Uri = St::Uri;
        type Version = St::Version;
    }
    ///State transition - sets the `issued_at` field to Set
    pub struct SetIssuedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIssuedAt<St> {}
    impl<St: State> State for SetIssuedAt<St> {
        type Address = St::Address;
        type ChainId = St::ChainId;
        type Domain = St::Domain;
        type IssuedAt = Set<members::issued_at>;
        type Nonce = St::Nonce;
        type Statement = St::Statement;
        type Uri = St::Uri;
        type Version = St::Version;
    }
    ///State transition - sets the `nonce` field to Set
    pub struct SetNonce<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetNonce<St> {}
    impl<St: State> State for SetNonce<St> {
        type Address = St::Address;
        type ChainId = St::ChainId;
        type Domain = St::Domain;
        type IssuedAt = St::IssuedAt;
        type Nonce = Set<members::nonce>;
        type Statement = St::Statement;
        type Uri = St::Uri;
        type Version = St::Version;
    }
    ///State transition - sets the `statement` field to Set
    pub struct SetStatement<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetStatement<St> {}
    impl<St: State> State for SetStatement<St> {
        type Address = St::Address;
        type ChainId = St::ChainId;
        type Domain = St::Domain;
        type IssuedAt = St::IssuedAt;
        type Nonce = St::Nonce;
        type Statement = Set<members::statement>;
        type Uri = St::Uri;
        type Version = St::Version;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Address = St::Address;
        type ChainId = St::ChainId;
        type Domain = St::Domain;
        type IssuedAt = St::IssuedAt;
        type Nonce = St::Nonce;
        type Statement = St::Statement;
        type Uri = Set<members::uri>;
        type Version = St::Version;
    }
    ///State transition - sets the `version` field to Set
    pub struct SetVersion<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetVersion<St> {}
    impl<St: State> State for SetVersion<St> {
        type Address = St::Address;
        type ChainId = St::ChainId;
        type Domain = St::Domain;
        type IssuedAt = St::IssuedAt;
        type Nonce = St::Nonce;
        type Statement = St::Statement;
        type Uri = St::Uri;
        type Version = Set<members::version>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `address` field
        pub struct address(());
        ///Marker type for the `chain_id` field
        pub struct chain_id(());
        ///Marker type for the `domain` field
        pub struct domain(());
        ///Marker type for the `issued_at` field
        pub struct issued_at(());
        ///Marker type for the `nonce` field
        pub struct nonce(());
        ///Marker type for the `statement` field
        pub struct statement(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `version` field
        pub struct version(());
    }
}

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

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

impl<S: BosStr> SiweMessage<S> {
    /// Create a new builder for this type
    pub fn builder() -> SiweMessageBuilder<siwe_message_state::Empty, S> {
        SiweMessageBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::Address: siwe_message_state::IsUnset,
{
    /// Set the `address` field (required)
    pub fn address(
        mut self,
        value: impl Into<S>,
    ) -> SiweMessageBuilder<siwe_message_state::SetAddress<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::ChainId: siwe_message_state::IsUnset,
{
    /// Set the `chainId` field (required)
    pub fn chain_id(
        mut self,
        value: impl Into<i64>,
    ) -> SiweMessageBuilder<siwe_message_state::SetChainId<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::Domain: siwe_message_state::IsUnset,
{
    /// Set the `domain` field (required)
    pub fn domain(
        mut self,
        value: impl Into<S>,
    ) -> SiweMessageBuilder<siwe_message_state::SetDomain<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::IssuedAt: siwe_message_state::IsUnset,
{
    /// Set the `issuedAt` field (required)
    pub fn issued_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> SiweMessageBuilder<siwe_message_state::SetIssuedAt<St>, S> {
        self._fields.3 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::Nonce: siwe_message_state::IsUnset,
{
    /// Set the `nonce` field (required)
    pub fn nonce(
        mut self,
        value: impl Into<S>,
    ) -> SiweMessageBuilder<siwe_message_state::SetNonce<St>, S> {
        self._fields.4 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::Statement: siwe_message_state::IsUnset,
{
    /// Set the `statement` field (required)
    pub fn statement(
        mut self,
        value: impl Into<S>,
    ) -> SiweMessageBuilder<siwe_message_state::SetStatement<St>, S> {
        self._fields.5 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::Uri: siwe_message_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> SiweMessageBuilder<siwe_message_state::SetUri<St>, S> {
        self._fields.6 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::Version: siwe_message_state::IsUnset,
{
    /// Set the `version` field (required)
    pub fn version(
        mut self,
        value: impl Into<S>,
    ) -> SiweMessageBuilder<siwe_message_state::SetVersion<St>, S> {
        self._fields.7 = Option::Some(value.into());
        SiweMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SiweMessageBuilder<St, S>
where
    St: siwe_message_state::State,
    St::Address: siwe_message_state::IsSet,
    St::ChainId: siwe_message_state::IsSet,
    St::Domain: siwe_message_state::IsSet,
    St::IssuedAt: siwe_message_state::IsSet,
    St::Nonce: siwe_message_state::IsSet,
    St::Statement: siwe_message_state::IsSet,
    St::Uri: siwe_message_state::IsSet,
    St::Version: siwe_message_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SiweMessage<S> {
        SiweMessage {
            address: self._fields.0.unwrap(),
            chain_id: self._fields.1.unwrap(),
            domain: self._fields.2.unwrap(),
            issued_at: self._fields.3.unwrap(),
            nonce: self._fields.4.unwrap(),
            statement: self._fields.5.unwrap(),
            uri: self._fields.6.unwrap(),
            version: self._fields.7.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>>,
    ) -> SiweMessage<S> {
        SiweMessage {
            address: self._fields.0.unwrap(),
            chain_id: self._fields.1.unwrap(),
            domain: self._fields.2.unwrap(),
            issued_at: self._fields.3.unwrap(),
            nonce: self._fields.4.unwrap(),
            statement: self._fields.5.unwrap(),
            uri: self._fields.6.unwrap(),
            version: self._fields.7.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}