#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct DataPoint<'a> {
pub date: jacquard_common::types::string::Datetime,
pub value: i64,
}
pub mod data_point_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 Date;
type Value;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Date = Unset;
type Value = Unset;
}
pub struct SetDate<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDate<S> {}
impl<S: State> State for SetDate<S> {
type Date = Set<members::date>;
type Value = S::Value;
}
pub struct SetValue<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetValue<S> {}
impl<S: State> State for SetValue<S> {
type Date = S::Date;
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct date(());
pub struct value(());
}
}
pub struct DataPointBuilder<'a, S: data_point_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<i64>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> DataPoint<'a> {
pub fn new() -> DataPointBuilder<'a, data_point_state::Empty> {
DataPointBuilder::new()
}
}
impl<'a> DataPointBuilder<'a, data_point_state::Empty> {
pub fn new() -> Self {
DataPointBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> DataPointBuilder<'a, S>
where
S: data_point_state::State,
S::Date: data_point_state::IsUnset,
{
pub fn date(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> DataPointBuilder<'a, data_point_state::SetDate<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
DataPointBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> DataPointBuilder<'a, S>
where
S: data_point_state::State,
S::Value: data_point_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<i64>,
) -> DataPointBuilder<'a, data_point_state::SetValue<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
DataPointBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> DataPointBuilder<'a, S>
where
S: data_point_state::State,
S::Date: data_point_state::IsSet,
S::Value: data_point_state::IsSet,
{
pub fn build(self) -> DataPoint<'a> {
DataPoint {
date: self.__unsafe_private_named.0.unwrap(),
value: self.__unsafe_private_named.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> DataPoint<'a> {
DataPoint {
date: self.__unsafe_private_named.0.unwrap(),
value: self.__unsafe_private_named.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_fitsky_trend() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("app.fitsky.trend"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("dataPoint"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("date"),
::jacquard_common::deps::smol_str::SmolStr::new_static("value")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"date",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"value",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: None,
maximum: None,
r#enum: None,
r#const: None,
}),
);
map
},
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"A shared fitness trend or dashboard snapshot",
),
),
key: Some(::jacquard_common::CowStr::new_static("tid")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("widgetType"),
::jacquard_common::deps::smol_str::SmolStr::new_static("metric"),
::jacquard_common::deps::smol_str::SmolStr::new_static("period"),
::jacquard_common::deps::smol_str::SmolStr::new_static("summary"),
::jacquard_common::deps::smol_str::SmolStr::new_static("createdAt")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"caption",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(512usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"chartStyle",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(64usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"createdAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"dataPoints",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static("#dataPoint"),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"image",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
description: None,
accept: None,
max_size: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"metric",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(64usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"period",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(64usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"summary",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"#trendSummary",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"widgetType",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(64usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("trendSummary"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: None,
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"average",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: None,
maximum: None,
r#enum: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"best",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: None,
maximum: None,
r#enum: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"count",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: None,
maximum: None,
r#enum: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"total",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: None,
maximum: None,
r#enum: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"worst",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: None,
maximum: None,
r#enum: None,
r#const: None,
}),
);
map
},
}),
);
map
},
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for DataPoint<'a> {
fn nsid() -> &'static str {
"app.fitsky.trend"
}
fn def_name() -> &'static str {
"dataPoint"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_app_fitsky_trend()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Trend<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub caption: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub chart_style: std::option::Option<TrendChartStyle<'a>>,
pub created_at: jacquard_common::types::string::Datetime,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub data_points: std::option::Option<Vec<crate::app_fitsky::trend::DataPoint<'a>>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub image: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
#[serde(borrow)]
pub metric: TrendMetric<'a>,
#[serde(borrow)]
pub period: TrendPeriod<'a>,
#[serde(borrow)]
pub summary: crate::app_fitsky::trend::TrendSummary<'a>,
#[serde(borrow)]
pub widget_type: TrendWidgetType<'a>,
}
pub mod trend_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 WidgetType;
type Period;
type Summary;
type CreatedAt;
type Metric;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type WidgetType = Unset;
type Period = Unset;
type Summary = Unset;
type CreatedAt = Unset;
type Metric = Unset;
}
pub struct SetWidgetType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWidgetType<S> {}
impl<S: State> State for SetWidgetType<S> {
type WidgetType = Set<members::widget_type>;
type Period = S::Period;
type Summary = S::Summary;
type CreatedAt = S::CreatedAt;
type Metric = S::Metric;
}
pub struct SetPeriod<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPeriod<S> {}
impl<S: State> State for SetPeriod<S> {
type WidgetType = S::WidgetType;
type Period = Set<members::period>;
type Summary = S::Summary;
type CreatedAt = S::CreatedAt;
type Metric = S::Metric;
}
pub struct SetSummary<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSummary<S> {}
impl<S: State> State for SetSummary<S> {
type WidgetType = S::WidgetType;
type Period = S::Period;
type Summary = Set<members::summary>;
type CreatedAt = S::CreatedAt;
type Metric = S::Metric;
}
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 WidgetType = S::WidgetType;
type Period = S::Period;
type Summary = S::Summary;
type CreatedAt = Set<members::created_at>;
type Metric = S::Metric;
}
pub struct SetMetric<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMetric<S> {}
impl<S: State> State for SetMetric<S> {
type WidgetType = S::WidgetType;
type Period = S::Period;
type Summary = S::Summary;
type CreatedAt = S::CreatedAt;
type Metric = Set<members::metric>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct widget_type(());
pub struct period(());
pub struct summary(());
pub struct created_at(());
pub struct metric(());
}
}
pub struct TrendBuilder<'a, S: trend_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<TrendChartStyle<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<Vec<crate::app_fitsky::trend::DataPoint<'a>>>,
::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
::core::option::Option<TrendMetric<'a>>,
::core::option::Option<TrendPeriod<'a>>,
::core::option::Option<crate::app_fitsky::trend::TrendSummary<'a>>,
::core::option::Option<TrendWidgetType<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Trend<'a> {
pub fn new() -> TrendBuilder<'a, trend_state::Empty> {
TrendBuilder::new()
}
}
impl<'a> TrendBuilder<'a, trend_state::Empty> {
pub fn new() -> Self {
TrendBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: trend_state::State> TrendBuilder<'a, S> {
pub fn caption(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_caption(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S: trend_state::State> TrendBuilder<'a, S> {
pub fn chart_style(mut self, value: impl Into<Option<TrendChartStyle<'a>>>) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_chart_style(mut self, value: Option<TrendChartStyle<'a>>) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S> TrendBuilder<'a, S>
where
S: trend_state::State,
S::CreatedAt: trend_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> TrendBuilder<'a, trend_state::SetCreatedAt<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
TrendBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: trend_state::State> TrendBuilder<'a, S> {
pub fn data_points(
mut self,
value: impl Into<Option<Vec<crate::app_fitsky::trend::DataPoint<'a>>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_data_points(
mut self,
value: Option<Vec<crate::app_fitsky::trend::DataPoint<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S: trend_state::State> TrendBuilder<'a, S> {
pub fn image(
mut self,
value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_image(
mut self,
value: Option<jacquard_common::types::blob::BlobRef<'a>>,
) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S> TrendBuilder<'a, S>
where
S: trend_state::State,
S::Metric: trend_state::IsUnset,
{
pub fn metric(
mut self,
value: impl Into<TrendMetric<'a>>,
) -> TrendBuilder<'a, trend_state::SetMetric<S>> {
self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
TrendBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TrendBuilder<'a, S>
where
S: trend_state::State,
S::Period: trend_state::IsUnset,
{
pub fn period(
mut self,
value: impl Into<TrendPeriod<'a>>,
) -> TrendBuilder<'a, trend_state::SetPeriod<S>> {
self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
TrendBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TrendBuilder<'a, S>
where
S: trend_state::State,
S::Summary: trend_state::IsUnset,
{
pub fn summary(
mut self,
value: impl Into<crate::app_fitsky::trend::TrendSummary<'a>>,
) -> TrendBuilder<'a, trend_state::SetSummary<S>> {
self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into());
TrendBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TrendBuilder<'a, S>
where
S: trend_state::State,
S::WidgetType: trend_state::IsUnset,
{
pub fn widget_type(
mut self,
value: impl Into<TrendWidgetType<'a>>,
) -> TrendBuilder<'a, trend_state::SetWidgetType<S>> {
self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into());
TrendBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TrendBuilder<'a, S>
where
S: trend_state::State,
S::WidgetType: trend_state::IsSet,
S::Period: trend_state::IsSet,
S::Summary: trend_state::IsSet,
S::CreatedAt: trend_state::IsSet,
S::Metric: trend_state::IsSet,
{
pub fn build(self) -> Trend<'a> {
Trend {
caption: self.__unsafe_private_named.0,
chart_style: self.__unsafe_private_named.1,
created_at: self.__unsafe_private_named.2.unwrap(),
data_points: self.__unsafe_private_named.3,
image: self.__unsafe_private_named.4,
metric: self.__unsafe_private_named.5.unwrap(),
period: self.__unsafe_private_named.6.unwrap(),
summary: self.__unsafe_private_named.7.unwrap(),
widget_type: self.__unsafe_private_named.8.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Trend<'a> {
Trend {
caption: self.__unsafe_private_named.0,
chart_style: self.__unsafe_private_named.1,
created_at: self.__unsafe_private_named.2.unwrap(),
data_points: self.__unsafe_private_named.3,
image: self.__unsafe_private_named.4,
metric: self.__unsafe_private_named.5.unwrap(),
period: self.__unsafe_private_named.6.unwrap(),
summary: self.__unsafe_private_named.7.unwrap(),
widget_type: self.__unsafe_private_named.8.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> Trend<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, TrendRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TrendChartStyle<'a> {
Line,
Bar,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> TrendChartStyle<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Line => "line",
Self::Bar => "bar",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for TrendChartStyle<'a> {
fn from(s: &'a str) -> Self {
match s {
"line" => Self::Line,
"bar" => Self::Bar,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for TrendChartStyle<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"line" => Self::Line,
"bar" => Self::Bar,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for TrendChartStyle<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for TrendChartStyle<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for TrendChartStyle<'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 TrendChartStyle<'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<'a> Default for TrendChartStyle<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for TrendChartStyle<'_> {
type Output = TrendChartStyle<'static>;
fn into_static(self) -> Self::Output {
match self {
TrendChartStyle::Line => TrendChartStyle::Line,
TrendChartStyle::Bar => TrendChartStyle::Bar,
TrendChartStyle::Other(v) => TrendChartStyle::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TrendMetric<'a> {
Distance,
Duration,
Pace,
Steps,
Calories,
HeartRate,
WorkoutCount,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> TrendMetric<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Distance => "distance",
Self::Duration => "duration",
Self::Pace => "pace",
Self::Steps => "steps",
Self::Calories => "calories",
Self::HeartRate => "heartRate",
Self::WorkoutCount => "workoutCount",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for TrendMetric<'a> {
fn from(s: &'a str) -> Self {
match s {
"distance" => Self::Distance,
"duration" => Self::Duration,
"pace" => Self::Pace,
"steps" => Self::Steps,
"calories" => Self::Calories,
"heartRate" => Self::HeartRate,
"workoutCount" => Self::WorkoutCount,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for TrendMetric<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"distance" => Self::Distance,
"duration" => Self::Duration,
"pace" => Self::Pace,
"steps" => Self::Steps,
"calories" => Self::Calories,
"heartRate" => Self::HeartRate,
"workoutCount" => Self::WorkoutCount,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for TrendMetric<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for TrendMetric<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for TrendMetric<'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 TrendMetric<'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<'a> Default for TrendMetric<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for TrendMetric<'_> {
type Output = TrendMetric<'static>;
fn into_static(self) -> Self::Output {
match self {
TrendMetric::Distance => TrendMetric::Distance,
TrendMetric::Duration => TrendMetric::Duration,
TrendMetric::Pace => TrendMetric::Pace,
TrendMetric::Steps => TrendMetric::Steps,
TrendMetric::Calories => TrendMetric::Calories,
TrendMetric::HeartRate => TrendMetric::HeartRate,
TrendMetric::WorkoutCount => TrendMetric::WorkoutCount,
TrendMetric::Other(v) => TrendMetric::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TrendPeriod<'a> {
_1d,
_7d,
_30d,
_90d,
_1y,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> TrendPeriod<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::_1d => "1d",
Self::_7d => "7d",
Self::_30d => "30d",
Self::_90d => "90d",
Self::_1y => "1y",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for TrendPeriod<'a> {
fn from(s: &'a str) -> Self {
match s {
"1d" => Self::_1d,
"7d" => Self::_7d,
"30d" => Self::_30d,
"90d" => Self::_90d,
"1y" => Self::_1y,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for TrendPeriod<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"1d" => Self::_1d,
"7d" => Self::_7d,
"30d" => Self::_30d,
"90d" => Self::_90d,
"1y" => Self::_1y,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for TrendPeriod<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for TrendPeriod<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for TrendPeriod<'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 TrendPeriod<'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<'a> Default for TrendPeriod<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for TrendPeriod<'_> {
type Output = TrendPeriod<'static>;
fn into_static(self) -> Self::Output {
match self {
TrendPeriod::_1d => TrendPeriod::_1d,
TrendPeriod::_7d => TrendPeriod::_7d,
TrendPeriod::_30d => TrendPeriod::_30d,
TrendPeriod::_90d => TrendPeriod::_90d,
TrendPeriod::_1y => TrendPeriod::_1y,
TrendPeriod::Other(v) => TrendPeriod::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TrendWidgetType<'a> {
TodaySummary,
WeeklyProgress,
GoalProgress,
RecentWorkouts,
CustomTrend,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> TrendWidgetType<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::TodaySummary => "today-summary",
Self::WeeklyProgress => "weekly-progress",
Self::GoalProgress => "goal-progress",
Self::RecentWorkouts => "recent-workouts",
Self::CustomTrend => "custom-trend",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for TrendWidgetType<'a> {
fn from(s: &'a str) -> Self {
match s {
"today-summary" => Self::TodaySummary,
"weekly-progress" => Self::WeeklyProgress,
"goal-progress" => Self::GoalProgress,
"recent-workouts" => Self::RecentWorkouts,
"custom-trend" => Self::CustomTrend,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for TrendWidgetType<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"today-summary" => Self::TodaySummary,
"weekly-progress" => Self::WeeklyProgress,
"goal-progress" => Self::GoalProgress,
"recent-workouts" => Self::RecentWorkouts,
"custom-trend" => Self::CustomTrend,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for TrendWidgetType<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for TrendWidgetType<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for TrendWidgetType<'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 TrendWidgetType<'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<'a> Default for TrendWidgetType<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for TrendWidgetType<'_> {
type Output = TrendWidgetType<'static>;
fn into_static(self) -> Self::Output {
match self {
TrendWidgetType::TodaySummary => TrendWidgetType::TodaySummary,
TrendWidgetType::WeeklyProgress => TrendWidgetType::WeeklyProgress,
TrendWidgetType::GoalProgress => TrendWidgetType::GoalProgress,
TrendWidgetType::RecentWorkouts => TrendWidgetType::RecentWorkouts,
TrendWidgetType::CustomTrend => TrendWidgetType::CustomTrend,
TrendWidgetType::Other(v) => TrendWidgetType::Other(v.into_static()),
}
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct TrendGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Trend<'a>,
}
impl From<TrendGetRecordOutput<'_>> for Trend<'_> {
fn from(output: TrendGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Trend<'_> {
const NSID: &'static str = "app.fitsky.trend";
type Record = TrendRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct TrendRecord;
impl jacquard_common::xrpc::XrpcResp for TrendRecord {
const NSID: &'static str = "app.fitsky.trend";
const ENCODING: &'static str = "application/json";
type Output<'de> = TrendGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for TrendRecord {
const NSID: &'static str = "app.fitsky.trend";
type Record = TrendRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Trend<'a> {
fn nsid() -> &'static str {
"app.fitsky.trend"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_app_fitsky_trend()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
if let Some(ref value) = self.caption {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"caption",
),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.chart_style {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"chart_style",
),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.image {
{
let size = value.blob().size;
if size > 1000000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobTooLarge {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"image",
),
max: 1000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.image {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobMimeTypeNotAccepted {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"image",
),
accepted: vec![
"image/png".to_string(), "image/jpeg".to_string()
],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.metric;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"metric",
),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.period;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"period",
),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.widget_type;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"widget_type",
),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic,
Default
)]
#[serde(rename_all = "camelCase")]
pub struct TrendSummary<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub average: std::option::Option<i64>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub best: std::option::Option<i64>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub count: std::option::Option<i64>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub total: std::option::Option<i64>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub worst: std::option::Option<i64>,
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for TrendSummary<'a> {
fn nsid() -> &'static str {
"app.fitsky.trend"
}
fn def_name() -> &'static str {
"trendSummary"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_app_fitsky_trend()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}