// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: social.pace.feed.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

//! Generated bindings for the `social.pace.feed` Lexicon namespace/module.
pub mod activity;


#[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::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};
/// The type of activity being recorded. List taken from Apple Health Activities mostly

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ActivityType<S: BosStr = DefaultStr> {
    Running,
    Walking,
    Cycling,
    Hiking,
    Swimming,
    Yoga,
    FunctionalTraining,
    StrengthTraining,
    Elliptical,
    Rowing,
    StairClimbing,
    Dancing,
    Golf,
    Tennis,
    Basketball,
    Soccer,
    Baseball,
    Football,
    Skiing,
    Snowboarding,
    Climbing,
    Boxing,
    MartialArts,
    JumpRope,
    Pilates,
    CrossTraining,
    MixedCardio,
    Hiit,
    CoreTraining,
    Flexibility,
    Cooldown,
    WheelchairWalk,
    WheelchairRun,
    Pickleball,
    Skating,
    OtherWorkout,
    Activity,
    Other(S),
}

impl<S: BosStr> ActivityType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Running => "Running",
            Self::Walking => "Walking",
            Self::Cycling => "Cycling",
            Self::Hiking => "Hiking",
            Self::Swimming => "Swimming",
            Self::Yoga => "Yoga",
            Self::FunctionalTraining => "Functional Training",
            Self::StrengthTraining => "Strength Training",
            Self::Elliptical => "Elliptical",
            Self::Rowing => "Rowing",
            Self::StairClimbing => "Stair Climbing",
            Self::Dancing => "Dancing",
            Self::Golf => "Golf",
            Self::Tennis => "Tennis",
            Self::Basketball => "Basketball",
            Self::Soccer => "Soccer",
            Self::Baseball => "Baseball",
            Self::Football => "Football",
            Self::Skiing => "Skiing",
            Self::Snowboarding => "Snowboarding",
            Self::Climbing => "Climbing",
            Self::Boxing => "Boxing",
            Self::MartialArts => "Martial Arts",
            Self::JumpRope => "Jump Rope",
            Self::Pilates => "Pilates",
            Self::CrossTraining => "Cross Training",
            Self::MixedCardio => "Mixed Cardio",
            Self::Hiit => "HIIT",
            Self::CoreTraining => "Core Training",
            Self::Flexibility => "Flexibility",
            Self::Cooldown => "Cooldown",
            Self::WheelchairWalk => "Wheelchair Walk",
            Self::WheelchairRun => "Wheelchair Run",
            Self::Pickleball => "Pickleball",
            Self::Skating => "Skating",
            Self::OtherWorkout => "Other Workout",
            Self::Activity => "Activity",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "Running" => Self::Running,
            "Walking" => Self::Walking,
            "Cycling" => Self::Cycling,
            "Hiking" => Self::Hiking,
            "Swimming" => Self::Swimming,
            "Yoga" => Self::Yoga,
            "Functional Training" => Self::FunctionalTraining,
            "Strength Training" => Self::StrengthTraining,
            "Elliptical" => Self::Elliptical,
            "Rowing" => Self::Rowing,
            "Stair Climbing" => Self::StairClimbing,
            "Dancing" => Self::Dancing,
            "Golf" => Self::Golf,
            "Tennis" => Self::Tennis,
            "Basketball" => Self::Basketball,
            "Soccer" => Self::Soccer,
            "Baseball" => Self::Baseball,
            "Football" => Self::Football,
            "Skiing" => Self::Skiing,
            "Snowboarding" => Self::Snowboarding,
            "Climbing" => Self::Climbing,
            "Boxing" => Self::Boxing,
            "Martial Arts" => Self::MartialArts,
            "Jump Rope" => Self::JumpRope,
            "Pilates" => Self::Pilates,
            "Cross Training" => Self::CrossTraining,
            "Mixed Cardio" => Self::MixedCardio,
            "HIIT" => Self::Hiit,
            "Core Training" => Self::CoreTraining,
            "Flexibility" => Self::Flexibility,
            "Cooldown" => Self::Cooldown,
            "Wheelchair Walk" => Self::WheelchairWalk,
            "Wheelchair Run" => Self::WheelchairRun,
            "Pickleball" => Self::Pickleball,
            "Skating" => Self::Skating,
            "Other Workout" => Self::OtherWorkout,
            "Activity" => Self::Activity,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> AsRef<str> for ActivityType<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> core::fmt::Display for ActivityType<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> Serialize for ActivityType<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for ActivityType<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for ActivityType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ActivityType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ActivityType::Running => ActivityType::Running,
            ActivityType::Walking => ActivityType::Walking,
            ActivityType::Cycling => ActivityType::Cycling,
            ActivityType::Hiking => ActivityType::Hiking,
            ActivityType::Swimming => ActivityType::Swimming,
            ActivityType::Yoga => ActivityType::Yoga,
            ActivityType::FunctionalTraining => ActivityType::FunctionalTraining,
            ActivityType::StrengthTraining => ActivityType::StrengthTraining,
            ActivityType::Elliptical => ActivityType::Elliptical,
            ActivityType::Rowing => ActivityType::Rowing,
            ActivityType::StairClimbing => ActivityType::StairClimbing,
            ActivityType::Dancing => ActivityType::Dancing,
            ActivityType::Golf => ActivityType::Golf,
            ActivityType::Tennis => ActivityType::Tennis,
            ActivityType::Basketball => ActivityType::Basketball,
            ActivityType::Soccer => ActivityType::Soccer,
            ActivityType::Baseball => ActivityType::Baseball,
            ActivityType::Football => ActivityType::Football,
            ActivityType::Skiing => ActivityType::Skiing,
            ActivityType::Snowboarding => ActivityType::Snowboarding,
            ActivityType::Climbing => ActivityType::Climbing,
            ActivityType::Boxing => ActivityType::Boxing,
            ActivityType::MartialArts => ActivityType::MartialArts,
            ActivityType::JumpRope => ActivityType::JumpRope,
            ActivityType::Pilates => ActivityType::Pilates,
            ActivityType::CrossTraining => ActivityType::CrossTraining,
            ActivityType::MixedCardio => ActivityType::MixedCardio,
            ActivityType::Hiit => ActivityType::Hiit,
            ActivityType::CoreTraining => ActivityType::CoreTraining,
            ActivityType::Flexibility => ActivityType::Flexibility,
            ActivityType::Cooldown => ActivityType::Cooldown,
            ActivityType::WheelchairWalk => ActivityType::WheelchairWalk,
            ActivityType::WheelchairRun => ActivityType::WheelchairRun,
            ActivityType::Pickleball => ActivityType::Pickleball,
            ActivityType::Skating => ActivityType::Skating,
            ActivityType::OtherWorkout => ActivityType::OtherWorkout,
            ActivityType::Activity => ActivityType::Activity,
            ActivityType::Other(v) => ActivityType::Other(v.into_static()),
        }
    }
}

/// A split within an activity, like a mile split or kilometer split.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Split<S: BosStr = DefaultStr> {
    ///The distance covered in this split. Follows the units defined in the parent.
    pub distance: S,
    ///The duration of the split in seconds.
    pub duration: i64,
    ///The order of the split within the activity, starting at 1.
    pub order: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Split<S> {
    fn nsid() -> &'static str {
        "social.pace.feed.defs"
    }
    fn def_name() -> &'static str {
        "split"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_pace_feed_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod split_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 Distance;
        type Duration;
        type Order;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Distance = Unset;
        type Duration = Unset;
        type Order = Unset;
    }
    ///State transition - sets the `distance` field to Set
    pub struct SetDistance<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDistance<St> {}
    impl<St: State> State for SetDistance<St> {
        type Distance = Set<members::distance>;
        type Duration = St::Duration;
        type Order = St::Order;
    }
    ///State transition - sets the `duration` field to Set
    pub struct SetDuration<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDuration<St> {}
    impl<St: State> State for SetDuration<St> {
        type Distance = St::Distance;
        type Duration = Set<members::duration>;
        type Order = St::Order;
    }
    ///State transition - sets the `order` field to Set
    pub struct SetOrder<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOrder<St> {}
    impl<St: State> State for SetOrder<St> {
        type Distance = St::Distance;
        type Duration = St::Duration;
        type Order = Set<members::order>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `distance` field
        pub struct distance(());
        ///Marker type for the `duration` field
        pub struct duration(());
        ///Marker type for the `order` field
        pub struct order(());
    }
}

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

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

impl<S: BosStr> Split<S> {
    /// Create a new builder for this type
    pub fn builder() -> SplitBuilder<split_state::Empty, S> {
        SplitBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SplitBuilder<St, S>
where
    St: split_state::State,
    St::Distance: split_state::IsUnset,
{
    /// Set the `distance` field (required)
    pub fn distance(
        mut self,
        value: impl Into<S>,
    ) -> SplitBuilder<split_state::SetDistance<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SplitBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SplitBuilder<St, S>
where
    St: split_state::State,
    St::Duration: split_state::IsUnset,
{
    /// Set the `duration` field (required)
    pub fn duration(
        mut self,
        value: impl Into<i64>,
    ) -> SplitBuilder<split_state::SetDuration<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SplitBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SplitBuilder<St, S>
where
    St: split_state::State,
    St::Order: split_state::IsUnset,
{
    /// Set the `order` field (required)
    pub fn order(
        mut self,
        value: impl Into<i64>,
    ) -> SplitBuilder<split_state::SetOrder<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SplitBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SplitBuilder<St, S>
where
    St: split_state::State,
    St::Distance: split_state::IsSet,
    St::Duration: split_state::IsSet,
    St::Order: split_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Split<S> {
        Split {
            distance: self._fields.0.unwrap(),
            duration: self._fields.1.unwrap(),
            order: 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<SmolStr, Data<S>>) -> Split<S> {
        Split {
            distance: self._fields.0.unwrap(),
            duration: self._fields.1.unwrap(),
            order: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_social_pace_feed_defs() -> 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.pace.feed.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("activityType"),
                LexUserType::String(LexString {
                    description: Some(
                        CowStr::new_static(
                            "The type of activity being recorded. List taken from Apple Health Activities mostly",
                        ),
                    ),
                    max_length: Some(50usize),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("split"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A split within an activity, like a mile split or kilometer split.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("order"),
                            SmolStr::new_static("distance"),
                            SmolStr::new_static("duration")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("distance"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The distance covered in this split. Follows the units defined in the parent.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("duration"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("order"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}