#[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")]
pub struct Ring<'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 RingGetRecordOutput<'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: Ring<'a>,
}
impl<'a> Ring<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, RingRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[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<'de> = RingGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<RingGetRecordOutput<'_>> for Ring<'_> {
fn from(output: RingGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Ring<'_> {
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<'a> LexiconSchema for Ring<'a> {
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 StandHours;
type ExerciseGoal;
type Exercise;
type Move;
type MoveGoal;
type StandGoal;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type StandHours = Unset;
type ExerciseGoal = Unset;
type Exercise = Unset;
type Move = Unset;
type MoveGoal = Unset;
type StandGoal = Unset;
type CreatedAt = Unset;
}
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 StandHours = Set<members::stand_hours>;
type ExerciseGoal = S::ExerciseGoal;
type Exercise = S::Exercise;
type Move = S::Move;
type MoveGoal = S::MoveGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
}
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 StandHours = S::StandHours;
type ExerciseGoal = Set<members::exercise_goal>;
type Exercise = S::Exercise;
type Move = S::Move;
type MoveGoal = S::MoveGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
}
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 StandHours = S::StandHours;
type ExerciseGoal = S::ExerciseGoal;
type Exercise = Set<members::exercise>;
type Move = S::Move;
type MoveGoal = S::MoveGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
}
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 StandHours = S::StandHours;
type ExerciseGoal = S::ExerciseGoal;
type Exercise = S::Exercise;
type Move = Set<members::r#move>;
type MoveGoal = S::MoveGoal;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
}
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 StandHours = S::StandHours;
type ExerciseGoal = S::ExerciseGoal;
type Exercise = S::Exercise;
type Move = S::Move;
type MoveGoal = Set<members::move_goal>;
type StandGoal = S::StandGoal;
type CreatedAt = S::CreatedAt;
}
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 StandHours = S::StandHours;
type ExerciseGoal = S::ExerciseGoal;
type Exercise = S::Exercise;
type Move = S::Move;
type MoveGoal = S::MoveGoal;
type StandGoal = Set<members::stand_goal>;
type CreatedAt = S::CreatedAt;
}
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 StandHours = S::StandHours;
type ExerciseGoal = S::ExerciseGoal;
type Exercise = S::Exercise;
type Move = S::Move;
type MoveGoal = S::MoveGoal;
type StandGoal = S::StandGoal;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct stand_hours(());
pub struct exercise_goal(());
pub struct exercise(());
pub struct r#move(());
pub struct move_goal(());
pub struct stand_goal(());
pub struct created_at(());
}
}
pub struct RingBuilder<'a, S: ring_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> Ring<'a> {
pub fn new() -> RingBuilder<'a, ring_state::Empty> {
RingBuilder::new()
}
}
impl<'a> RingBuilder<'a, ring_state::Empty> {
pub fn new() -> Self {
RingBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::CreatedAt: ring_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> RingBuilder<'a, ring_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::Exercise: ring_state::IsUnset,
{
pub fn exercise(
mut self,
value: impl Into<i64>,
) -> RingBuilder<'a, ring_state::SetExercise<S>> {
self._fields.1 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::ExerciseGoal: ring_state::IsUnset,
{
pub fn exercise_goal(
mut self,
value: impl Into<i64>,
) -> RingBuilder<'a, ring_state::SetExerciseGoal<S>> {
self._fields.2 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::Move: ring_state::IsUnset,
{
pub fn r#move(
mut self,
value: impl Into<i64>,
) -> RingBuilder<'a, ring_state::SetMove<S>> {
self._fields.3 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::MoveGoal: ring_state::IsUnset,
{
pub fn move_goal(
mut self,
value: impl Into<i64>,
) -> RingBuilder<'a, ring_state::SetMoveGoal<S>> {
self._fields.4 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::StandGoal: ring_state::IsUnset,
{
pub fn stand_goal(
mut self,
value: impl Into<i64>,
) -> RingBuilder<'a, ring_state::SetStandGoal<S>> {
self._fields.5 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::StandHours: ring_state::IsUnset,
{
pub fn stand_hours(
mut self,
value: impl Into<i64>,
) -> RingBuilder<'a, ring_state::SetStandHours<S>> {
self._fields.6 = Option::Some(value.into());
RingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RingBuilder<'a, S>
where
S: ring_state::State,
S::StandHours: ring_state::IsSet,
S::ExerciseGoal: ring_state::IsSet,
S::Exercise: ring_state::IsSet,
S::Move: ring_state::IsSet,
S::MoveGoal: ring_state::IsSet,
S::StandGoal: ring_state::IsSet,
S::CreatedAt: ring_state::IsSet,
{
pub fn build(self) -> Ring<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Ring<'a> {
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()
}
}