#[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};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "social.pace.goal.ring",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Ring<S: BosStr = DefaultStr> {
pub created_at: Datetime,
pub exercise: i64,
pub exercise_goal: i64,
pub r#move: i64,
pub move_goal: i64,
pub stand_goal: i64,
pub stand_hours: i64,
#[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")]
pub struct RingGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Ring<S>,
}
impl<S: BosStr> Ring<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, RingRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RingRecord;
impl XrpcResp for RingRecord {
const NSID: &'static str = "social.pace.goal.ring";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = RingGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<RingGetRecordOutput<S>> for Ring<S> {
fn from(output: RingGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Ring<S> {
const NSID: &'static str = "social.pace.goal.ring";
type Record = RingRecord;
}
impl Collection for RingRecord {
const NSID: &'static str = "social.pace.goal.ring";
type Record = RingRecord;
}
impl<S: BosStr> LexiconSchema for Ring<S> {
fn nsid() -> &'static str {
"social.pace.goal.ring"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_social_pace_goal_ring()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod ring_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type MoveGoal;
type Exercise;
type ExerciseGoal;
type StandGoal;
type Move;
type CreatedAt;
type StandHours;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type MoveGoal = Unset;
type Exercise = Unset;
type ExerciseGoal = Unset;
type StandGoal = Unset;
type Move = Unset;
type CreatedAt = Unset;
type StandHours = Unset;
}
pub struct SetMoveGoal<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMoveGoal<St> {}
impl<St: State> State for SetMoveGoal<St> {
type MoveGoal = Set<members::move_goal>;
type Exercise = St::Exercise;
type ExerciseGoal = St::ExerciseGoal;
type StandGoal = St::StandGoal;
type Move = St::Move;
type CreatedAt = St::CreatedAt;
type StandHours = St::StandHours;
}
pub struct SetExercise<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetExercise<St> {}
impl<St: State> State for SetExercise<St> {
type MoveGoal = St::MoveGoal;
type Exercise = Set<members::exercise>;
type ExerciseGoal = St::ExerciseGoal;
type StandGoal = St::StandGoal;
type Move = St::Move;
type CreatedAt = St::CreatedAt;
type StandHours = St::StandHours;
}
pub struct SetExerciseGoal<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetExerciseGoal<St> {}
impl<St: State> State for SetExerciseGoal<St> {
type MoveGoal = St::MoveGoal;
type Exercise = St::Exercise;
type ExerciseGoal = Set<members::exercise_goal>;
type StandGoal = St::StandGoal;
type Move = St::Move;
type CreatedAt = St::CreatedAt;
type StandHours = St::StandHours;
}
pub struct SetStandGoal<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStandGoal<St> {}
impl<St: State> State for SetStandGoal<St> {
type MoveGoal = St::MoveGoal;
type Exercise = St::Exercise;
type ExerciseGoal = St::ExerciseGoal;
type StandGoal = Set<members::stand_goal>;
type Move = St::Move;
type CreatedAt = St::CreatedAt;
type StandHours = St::StandHours;
}
pub struct SetMove<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMove<St> {}
impl<St: State> State for SetMove<St> {
type MoveGoal = St::MoveGoal;
type Exercise = St::Exercise;
type ExerciseGoal = St::ExerciseGoal;
type StandGoal = St::StandGoal;
type Move = Set<members::r#move>;
type CreatedAt = St::CreatedAt;
type StandHours = St::StandHours;
}
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 MoveGoal = St::MoveGoal;
type Exercise = St::Exercise;
type ExerciseGoal = St::ExerciseGoal;
type StandGoal = St::StandGoal;
type Move = St::Move;
type CreatedAt = Set<members::created_at>;
type StandHours = St::StandHours;
}
pub struct SetStandHours<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStandHours<St> {}
impl<St: State> State for SetStandHours<St> {
type MoveGoal = St::MoveGoal;
type Exercise = St::Exercise;
type ExerciseGoal = St::ExerciseGoal;
type StandGoal = St::StandGoal;
type Move = St::Move;
type CreatedAt = St::CreatedAt;
type StandHours = Set<members::stand_hours>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct move_goal(());
pub struct exercise(());
pub struct exercise_goal(());
pub struct stand_goal(());
pub struct r#move(());
pub struct created_at(());
pub struct stand_hours(());
}
}
pub struct RingBuilder<S: BosStr, St: ring_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Ring<S> {
pub fn new() -> RingBuilder<S, ring_state::Empty> {
RingBuilder::new()
}
}
impl<S: BosStr> RingBuilder<S, ring_state::Empty> {
pub fn new() -> Self {
RingBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::CreatedAt: ring_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> RingBuilder<S, ring_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::Exercise: ring_state::IsUnset,
{
pub fn exercise(
mut self,
value: impl Into<i64>,
) -> RingBuilder<S, ring_state::SetExercise<St>> {
self._fields.1 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::ExerciseGoal: ring_state::IsUnset,
{
pub fn exercise_goal(
mut self,
value: impl Into<i64>,
) -> RingBuilder<S, ring_state::SetExerciseGoal<St>> {
self._fields.2 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::Move: ring_state::IsUnset,
{
pub fn r#move(
mut self,
value: impl Into<i64>,
) -> RingBuilder<S, ring_state::SetMove<St>> {
self._fields.3 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::MoveGoal: ring_state::IsUnset,
{
pub fn move_goal(
mut self,
value: impl Into<i64>,
) -> RingBuilder<S, ring_state::SetMoveGoal<St>> {
self._fields.4 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::StandGoal: ring_state::IsUnset,
{
pub fn stand_goal(
mut self,
value: impl Into<i64>,
) -> RingBuilder<S, ring_state::SetStandGoal<St>> {
self._fields.5 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::StandHours: ring_state::IsUnset,
{
pub fn stand_hours(
mut self,
value: impl Into<i64>,
) -> RingBuilder<S, ring_state::SetStandHours<St>> {
self._fields.6 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RingBuilder<S, St>
where
St: ring_state::State,
St::MoveGoal: ring_state::IsSet,
St::Exercise: ring_state::IsSet,
St::ExerciseGoal: ring_state::IsSet,
St::StandGoal: ring_state::IsSet,
St::Move: ring_state::IsSet,
St::CreatedAt: ring_state::IsSet,
St::StandHours: ring_state::IsSet,
{
pub fn build(self) -> Ring<S> {
Ring {
created_at: self._fields.0.unwrap(),
exercise: self._fields.1.unwrap(),
exercise_goal: self._fields.2.unwrap(),
r#move: self._fields.3.unwrap(),
move_goal: self._fields.4.unwrap(),
stand_goal: self._fields.5.unwrap(),
stand_hours: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Ring<S> {
Ring {
created_at: self._fields.0.unwrap(),
exercise: self._fields.1.unwrap(),
exercise_goal: self._fields.2.unwrap(),
r#move: self._fields.3.unwrap(),
move_goal: self._fields.4.unwrap(),
stand_goal: self._fields.5.unwrap(),
stand_hours: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_social_pace_goal_ring() -> 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.goal.ring"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A record of daily activity rings (Apple Fitness), including move, exercise, and stand goals.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("move"),
SmolStr::new_static("moveGoal"),
SmolStr::new_static("exercise"),
SmolStr::new_static("exerciseGoal"),
SmolStr::new_static("standHours"),
SmolStr::new_static("standGoal"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("exercise"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("exerciseGoal"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("move"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("moveGoal"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("standGoal"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("standHours"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}