#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct WorkoutPlan<'a> {
pub created_at: jacquard_common::types::string::Datetime,
#[serde(borrow)]
pub exercises: Vec<crate::app_fitsky::workout_plan::PlanExercise<'a>>,
#[serde(borrow)]
pub name: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub og_image: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
#[serde(borrow)]
pub r#type: WorkoutPlanType<'a>,
}
pub mod workout_plan_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 CreatedAt;
type Type;
type Name;
type Exercises;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Type = Unset;
type Name = Unset;
type Exercises = Unset;
}
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 CreatedAt = Set<members::created_at>;
type Type = S::Type;
type Name = S::Name;
type Exercises = S::Exercises;
}
pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetType<S> {}
impl<S: State> State for SetType<S> {
type CreatedAt = S::CreatedAt;
type Type = Set<members::r#type>;
type Name = S::Name;
type Exercises = S::Exercises;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type CreatedAt = S::CreatedAt;
type Type = S::Type;
type Name = Set<members::name>;
type Exercises = S::Exercises;
}
pub struct SetExercises<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetExercises<S> {}
impl<S: State> State for SetExercises<S> {
type CreatedAt = S::CreatedAt;
type Type = S::Type;
type Name = S::Name;
type Exercises = Set<members::exercises>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct r#type(());
pub struct name(());
pub struct exercises(());
}
}
pub struct WorkoutPlanBuilder<'a, S: workout_plan_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<Vec<crate::app_fitsky::workout_plan::PlanExercise<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
::core::option::Option<WorkoutPlanType<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> WorkoutPlan<'a> {
pub fn new() -> WorkoutPlanBuilder<'a, workout_plan_state::Empty> {
WorkoutPlanBuilder::new()
}
}
impl<'a> WorkoutPlanBuilder<'a, workout_plan_state::Empty> {
pub fn new() -> Self {
WorkoutPlanBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WorkoutPlanBuilder<'a, S>
where
S: workout_plan_state::State,
S::CreatedAt: workout_plan_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> WorkoutPlanBuilder<'a, workout_plan_state::SetCreatedAt<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
WorkoutPlanBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WorkoutPlanBuilder<'a, S>
where
S: workout_plan_state::State,
S::Exercises: workout_plan_state::IsUnset,
{
pub fn exercises(
mut self,
value: impl Into<Vec<crate::app_fitsky::workout_plan::PlanExercise<'a>>>,
) -> WorkoutPlanBuilder<'a, workout_plan_state::SetExercises<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
WorkoutPlanBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WorkoutPlanBuilder<'a, S>
where
S: workout_plan_state::State,
S::Name: workout_plan_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> WorkoutPlanBuilder<'a, workout_plan_state::SetName<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
WorkoutPlanBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: workout_plan_state::State> WorkoutPlanBuilder<'a, S> {
pub fn og_image(
mut self,
value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_og_image(
mut self,
value: Option<jacquard_common::types::blob::BlobRef<'a>>,
) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S> WorkoutPlanBuilder<'a, S>
where
S: workout_plan_state::State,
S::Type: workout_plan_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<WorkoutPlanType<'a>>,
) -> WorkoutPlanBuilder<'a, workout_plan_state::SetType<S>> {
self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
WorkoutPlanBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WorkoutPlanBuilder<'a, S>
where
S: workout_plan_state::State,
S::CreatedAt: workout_plan_state::IsSet,
S::Type: workout_plan_state::IsSet,
S::Name: workout_plan_state::IsSet,
S::Exercises: workout_plan_state::IsSet,
{
pub fn build(self) -> WorkoutPlan<'a> {
WorkoutPlan {
created_at: self.__unsafe_private_named.0.unwrap(),
exercises: self.__unsafe_private_named.1.unwrap(),
name: self.__unsafe_private_named.2.unwrap(),
og_image: self.__unsafe_private_named.3,
r#type: self.__unsafe_private_named.4.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>,
>,
) -> WorkoutPlan<'a> {
WorkoutPlan {
created_at: self.__unsafe_private_named.0.unwrap(),
exercises: self.__unsafe_private_named.1.unwrap(),
name: self.__unsafe_private_named.2.unwrap(),
og_image: self.__unsafe_private_named.3,
r#type: self.__unsafe_private_named.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> WorkoutPlan<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, WorkoutPlanRecord>,
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 WorkoutPlanType<'a> {
Weightlifting,
Bodyweight,
Yoga,
Hiit,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> WorkoutPlanType<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Weightlifting => "weightlifting",
Self::Bodyweight => "bodyweight",
Self::Yoga => "yoga",
Self::Hiit => "hiit",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for WorkoutPlanType<'a> {
fn from(s: &'a str) -> Self {
match s {
"weightlifting" => Self::Weightlifting,
"bodyweight" => Self::Bodyweight,
"yoga" => Self::Yoga,
"hiit" => Self::Hiit,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for WorkoutPlanType<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"weightlifting" => Self::Weightlifting,
"bodyweight" => Self::Bodyweight,
"yoga" => Self::Yoga,
"hiit" => Self::Hiit,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for WorkoutPlanType<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for WorkoutPlanType<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for WorkoutPlanType<'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 WorkoutPlanType<'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 WorkoutPlanType<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for WorkoutPlanType<'_> {
type Output = WorkoutPlanType<'static>;
fn into_static(self) -> Self::Output {
match self {
WorkoutPlanType::Weightlifting => WorkoutPlanType::Weightlifting,
WorkoutPlanType::Bodyweight => WorkoutPlanType::Bodyweight,
WorkoutPlanType::Yoga => WorkoutPlanType::Yoga,
WorkoutPlanType::Hiit => WorkoutPlanType::Hiit,
WorkoutPlanType::Other(v) => WorkoutPlanType::Other(v.into_static()),
}
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct WorkoutPlanGetRecordOutput<'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: WorkoutPlan<'a>,
}
impl From<WorkoutPlanGetRecordOutput<'_>> for WorkoutPlan<'_> {
fn from(output: WorkoutPlanGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for WorkoutPlan<'_> {
const NSID: &'static str = "app.fitsky.workoutPlan";
type Record = WorkoutPlanRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct WorkoutPlanRecord;
impl jacquard_common::xrpc::XrpcResp for WorkoutPlanRecord {
const NSID: &'static str = "app.fitsky.workoutPlan";
const ENCODING: &'static str = "application/json";
type Output<'de> = WorkoutPlanGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for WorkoutPlanRecord {
const NSID: &'static str = "app.fitsky.workoutPlan";
type Record = WorkoutPlanRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for WorkoutPlan<'a> {
fn nsid() -> &'static str {
"app.fitsky.workoutPlan"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_app_fitsky_workoutPlan()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"name",
),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.og_image {
{
let size = value.blob().size;
if size > 1000000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobTooLarge {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"og_image",
),
max: 1000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.og_image {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg", "image/webp"];
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(
"og_image",
),
accepted: vec![
"image/png".to_string(), "image/jpeg".to_string(),
"image/webp".to_string()
],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.r#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(
"type",
),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_app_fitsky_workoutPlan() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("app.fitsky.workoutPlan"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
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 reusable workout plan template",
),
),
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("name"),
::jacquard_common::deps::smol_str::SmolStr::new_static("type"),
::jacquard_common::deps::smol_str::SmolStr::new_static("exercises"),
::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(
"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(
"exercises",
),
::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(
"#planExercise",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"name",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(256usize),
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(
"ogImage",
),
::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(
"type",
),
::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("planExercise"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("name"),
::jacquard_common::deps::smol_str::SmolStr::new_static("targetSets"),
::jacquard_common::deps::smol_str::SmolStr::new_static("targetReps")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"name",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
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(
"notes",
),
::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(
"targetReps",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: Some(1i64),
maximum: None,
r#enum: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"targetSets",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: Some(1i64),
maximum: None,
r#enum: None,
r#const: None,
}),
);
map
},
}),
);
map
},
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct PlanExercise<'a> {
#[serde(borrow)]
pub name: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub notes: std::option::Option<jacquard_common::CowStr<'a>>,
pub target_reps: i64,
pub target_sets: i64,
}
pub mod plan_exercise_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 TargetSets;
type Name;
type TargetReps;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type TargetSets = Unset;
type Name = Unset;
type TargetReps = Unset;
}
pub struct SetTargetSets<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTargetSets<S> {}
impl<S: State> State for SetTargetSets<S> {
type TargetSets = Set<members::target_sets>;
type Name = S::Name;
type TargetReps = S::TargetReps;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type TargetSets = S::TargetSets;
type Name = Set<members::name>;
type TargetReps = S::TargetReps;
}
pub struct SetTargetReps<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTargetReps<S> {}
impl<S: State> State for SetTargetReps<S> {
type TargetSets = S::TargetSets;
type Name = S::Name;
type TargetReps = Set<members::target_reps>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct target_sets(());
pub struct name(());
pub struct target_reps(());
}
}
pub struct PlanExerciseBuilder<'a, S: plan_exercise_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<i64>,
::core::option::Option<i64>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> PlanExercise<'a> {
pub fn new() -> PlanExerciseBuilder<'a, plan_exercise_state::Empty> {
PlanExerciseBuilder::new()
}
}
impl<'a> PlanExerciseBuilder<'a, plan_exercise_state::Empty> {
pub fn new() -> Self {
PlanExerciseBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PlanExerciseBuilder<'a, S>
where
S: plan_exercise_state::State,
S::Name: plan_exercise_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> PlanExerciseBuilder<'a, plan_exercise_state::SetName<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
PlanExerciseBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: plan_exercise_state::State> PlanExerciseBuilder<'a, S> {
pub fn notes(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_notes(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S> PlanExerciseBuilder<'a, S>
where
S: plan_exercise_state::State,
S::TargetReps: plan_exercise_state::IsUnset,
{
pub fn target_reps(
mut self,
value: impl Into<i64>,
) -> PlanExerciseBuilder<'a, plan_exercise_state::SetTargetReps<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
PlanExerciseBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PlanExerciseBuilder<'a, S>
where
S: plan_exercise_state::State,
S::TargetSets: plan_exercise_state::IsUnset,
{
pub fn target_sets(
mut self,
value: impl Into<i64>,
) -> PlanExerciseBuilder<'a, plan_exercise_state::SetTargetSets<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
PlanExerciseBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PlanExerciseBuilder<'a, S>
where
S: plan_exercise_state::State,
S::TargetSets: plan_exercise_state::IsSet,
S::Name: plan_exercise_state::IsSet,
S::TargetReps: plan_exercise_state::IsSet,
{
pub fn build(self) -> PlanExercise<'a> {
PlanExercise {
name: self.__unsafe_private_named.0.unwrap(),
notes: self.__unsafe_private_named.1,
target_reps: self.__unsafe_private_named.2.unwrap(),
target_sets: self.__unsafe_private_named.3.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>,
>,
) -> PlanExercise<'a> {
PlanExercise {
name: self.__unsafe_private_named.0.unwrap(),
notes: self.__unsafe_private_named.1,
target_reps: self.__unsafe_private_named.2.unwrap(),
target_sets: self.__unsafe_private_named.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for PlanExercise<'a> {
fn nsid() -> &'static str {
"app.fitsky.workoutPlan"
}
fn def_name() -> &'static str {
"planExercise"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_app_fitsky_workoutPlan()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"name",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.notes {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"notes",
),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.target_reps;
if *value < 1i64 {
return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"target_reps",
),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.target_sets;
if *value < 1i64 {
return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"target_sets",
),
min: 1i64,
actual: *value,
});
}
}
Ok(())
}
}