#[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_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
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};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "dev.baileytownsend.health.rings",
tag = "$type"
)]
pub struct Rings<'a> {
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,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RingsGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Rings<'a>,
}
impl<'a> Rings<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, RingsRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RingsRecord;
impl XrpcResp for RingsRecord {
const NSID: &'static str = "dev.baileytownsend.health.rings";
const ENCODING: &'static str = "application/json";
type Output<'de> = RingsGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<RingsGetRecordOutput<'_>> for Rings<'_> {
fn from(output: RingsGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Rings<'_> {
const NSID: &'static str = "dev.baileytownsend.health.rings";
type Record = RingsRecord;
}
impl Collection for RingsRecord {
const NSID: &'static str = "dev.baileytownsend.health.rings";
type Record = RingsRecord;
}
impl<'a> LexiconSchema for Rings<'a> {
fn nsid() -> &'static str {
"dev.baileytownsend.health.rings"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_baileytownsend_health_rings()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod rings_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 ExerciseGoal;
type StandGoal;
type CreatedAt;
type StandHours;
type Exercise;
type MoveGoal;
type Move;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ExerciseGoal = Unset;
type StandGoal = Unset;
type CreatedAt = Unset;
type StandHours = Unset;
type Exercise = Unset;
type MoveGoal = Unset;
type Move = Unset;
}
pub struct SetExerciseGoal<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetExerciseGoal<S> {}
impl<S: State> State for SetExerciseGoal<S> {
type ExerciseGoal = Set<members::exercise_goal>;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
type StandHours = S::StandHours;
type Exercise = S::Exercise;
type MoveGoal = S::MoveGoal;
type Move = S::Move;
}
pub struct SetStandGoal<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStandGoal<S> {}
impl<S: State> State for SetStandGoal<S> {
type ExerciseGoal = S::ExerciseGoal;
type StandGoal = Set<members::stand_goal>;
type CreatedAt = S::CreatedAt;
type StandHours = S::StandHours;
type Exercise = S::Exercise;
type MoveGoal = S::MoveGoal;
type Move = S::Move;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type ExerciseGoal = S::ExerciseGoal;
type StandGoal = S::StandGoal;
type CreatedAt = Set<members::created_at>;
type StandHours = S::StandHours;
type Exercise = S::Exercise;
type MoveGoal = S::MoveGoal;
type Move = S::Move;
}
pub struct SetStandHours<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStandHours<S> {}
impl<S: State> State for SetStandHours<S> {
type ExerciseGoal = S::ExerciseGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
type StandHours = Set<members::stand_hours>;
type Exercise = S::Exercise;
type MoveGoal = S::MoveGoal;
type Move = S::Move;
}
pub struct SetExercise<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetExercise<S> {}
impl<S: State> State for SetExercise<S> {
type ExerciseGoal = S::ExerciseGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
type StandHours = S::StandHours;
type Exercise = Set<members::exercise>;
type MoveGoal = S::MoveGoal;
type Move = S::Move;
}
pub struct SetMoveGoal<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMoveGoal<S> {}
impl<S: State> State for SetMoveGoal<S> {
type ExerciseGoal = S::ExerciseGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
type StandHours = S::StandHours;
type Exercise = S::Exercise;
type MoveGoal = Set<members::move_goal>;
type Move = S::Move;
}
pub struct SetMove<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMove<S> {}
impl<S: State> State for SetMove<S> {
type ExerciseGoal = S::ExerciseGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
type StandHours = S::StandHours;
type Exercise = S::Exercise;
type MoveGoal = S::MoveGoal;
type Move = Set<members::r#move>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct exercise_goal(());
pub struct stand_goal(());
pub struct created_at(());
pub struct stand_hours(());
pub struct exercise(());
pub struct move_goal(());
pub struct r#move(());
}
}
pub struct RingsBuilder<'a, S: rings_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Rings<'a> {
pub fn new() -> RingsBuilder<'a, rings_state::Empty> {
RingsBuilder::new()
}
}
impl<'a> RingsBuilder<'a, rings_state::Empty> {
pub fn new() -> Self {
RingsBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::CreatedAt: rings_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> RingsBuilder<'a, rings_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
RingsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::Exercise: rings_state::IsUnset,
{
pub fn exercise(
mut self,
value: impl Into<i64>,
) -> RingsBuilder<'a, rings_state::SetExercise<S>> {
self._fields.1 = Option::Some(value.into());
RingsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::ExerciseGoal: rings_state::IsUnset,
{
pub fn exercise_goal(
mut self,
value: impl Into<i64>,
) -> RingsBuilder<'a, rings_state::SetExerciseGoal<S>> {
self._fields.2 = Option::Some(value.into());
RingsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::Move: rings_state::IsUnset,
{
pub fn r#move(
mut self,
value: impl Into<i64>,
) -> RingsBuilder<'a, rings_state::SetMove<S>> {
self._fields.3 = Option::Some(value.into());
RingsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::MoveGoal: rings_state::IsUnset,
{
pub fn move_goal(
mut self,
value: impl Into<i64>,
) -> RingsBuilder<'a, rings_state::SetMoveGoal<S>> {
self._fields.4 = Option::Some(value.into());
RingsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::StandGoal: rings_state::IsUnset,
{
pub fn stand_goal(
mut self,
value: impl Into<i64>,
) -> RingsBuilder<'a, rings_state::SetStandGoal<S>> {
self._fields.5 = Option::Some(value.into());
RingsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::StandHours: rings_state::IsUnset,
{
pub fn stand_hours(
mut self,
value: impl Into<i64>,
) -> RingsBuilder<'a, rings_state::SetStandHours<S>> {
self._fields.6 = Option::Some(value.into());
RingsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingsBuilder<'a, S>
where
S: rings_state::State,
S::ExerciseGoal: rings_state::IsSet,
S::StandGoal: rings_state::IsSet,
S::CreatedAt: rings_state::IsSet,
S::StandHours: rings_state::IsSet,
S::Exercise: rings_state::IsSet,
S::MoveGoal: rings_state::IsSet,
S::Move: rings_state::IsSet,
{
pub fn build(self) -> Rings<'a> {
Rings {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Rings<'a> {
Rings {
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_dev_baileytownsend_health_rings() -> 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("dev.baileytownsend.health.rings"),
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()
}
}