//! This code was AUTOGENERATED using the Codama library.
use {carbon_core::graphql::primitives::U8, juniper::GraphQLObject};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PermissionlessFarmSwitch")]
pub struct PermissionlessFarmSwitchGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub bump: U8,
    pub is_on: bool,
}

impl TryFrom<crate::accounts::postgres::PermissionlessFarmSwitchRow>
    for PermissionlessFarmSwitchGraphQL
{
    type Error = carbon_core::error::Error;
    fn try_from(
        row: crate::accounts::postgres::PermissionlessFarmSwitchRow,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
            is_on: row.is_on,
        })
    }
}
