// @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.

pub mod activity;


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

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ActivityType<'a> {
    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(CowStr<'a>),
}

impl<'a> ActivityType<'a> {
    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(),
        }
    }
}

impl<'a> From<&'a str> for ActivityType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "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(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for ActivityType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "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(CowStr::from(s)),
        }
    }
}

impl<'a> AsRef<str> for ActivityType<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

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

impl<'de, 'a> serde::Deserialize<'de> for ActivityType<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl jacquard_common::IntoStatic for ActivityType<'_> {
    type Output = ActivityType<'static>;
    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.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Split<'a> {
    ///The distance covered in this split. Follows the units defined in the parent.
    #[serde(borrow)]
    pub distance: CowStr<'a>,
    ///The duration of the split in seconds.
    pub duration: i64,
    ///The order of the split within the activity, starting at 1.
    pub order: i64,
}

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

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

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

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

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

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

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

impl<'a, S> SplitBuilder<'a, S>
where
    S: split_state::State,
    S::Order: split_state::IsSet,
    S::Duration: split_state::IsSet,
    S::Distance: split_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Split<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Split<'a> {
        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()
    }
}