// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: pub.quizzy.quiz // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[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, Language}; 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}; use crate::com_atproto::repo::strong_ref::StrongRef; use crate::pub_quizzy::quiz; /// A quiz containing one or more rounds of questions #[lexicon] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase")] pub struct Quiz<'a> { ///A short description about the quiz, and what to expect from it #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub description: Option>, ///This quiz includes questions with audio, eg. a music round Defaults to `false`. #[serde(skip_serializing_if = "Option::is_none")] #[serde(default = "_default_quiz_has_audio")] pub has_audio: Option, ///This quiz includes questions with visuals, eg. a picture round Defaults to `false`. #[serde(skip_serializing_if = "Option::is_none")] #[serde(default = "_default_quiz_has_visuals")] pub has_visuals: Option, ///Dominant language(s) of the quiz pub locales: Vec, ///If this is an edit or revision of a previous quiz, link that previous version here. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub revision_of: Option>, ///Ordered list of rounds in this quiz #[serde(borrow)] pub rounds: Vec>, ///When this quiz was created pub timestamp: Datetime, ///A title for the quiz #[serde(borrow)] pub title: CowStr<'a>, } /// Typed wrapper for GetRecord response with this collection's record type. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase")] pub struct QuizGetRecordOutput<'a> { #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub cid: Option>, #[serde(borrow)] pub uri: AtUri<'a>, #[serde(borrow)] pub value: Quiz<'a>, } /// Reference to a question with its point value #[lexicon] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase")] pub struct QuestionRef<'a> { ///A custom name for this question, as opposed to its number #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub name: Option>, ///Points awarded for complete correctness Defaults to `1`. #[serde(skip_serializing_if = "Option::is_none")] #[serde(default = "_default_question_ref_points")] pub points: Option, #[serde(borrow)] pub question: StrongRef<'a>, } /// A round within a quiz #[lexicon] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase")] pub struct Round<'a> { ///Ordered list of questions in this round #[serde(borrow)] pub questions: Vec>, ///Optional title for this round (requires locale if set) #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub title: Option>, } impl<'a> Quiz<'a> { pub fn uri( uri: impl Into>, ) -> Result, UriError> { RecordUri::try_from_uri(AtUri::new_cow(uri.into())?) } } /// Marker type for deserializing records from this collection. #[derive(Debug, Serialize, Deserialize)] pub struct QuizRecord; impl XrpcResp for QuizRecord { const NSID: &'static str = "pub.quizzy.quiz"; const ENCODING: &'static str = "application/json"; type Output<'de> = QuizGetRecordOutput<'de>; type Err<'de> = RecordError<'de>; } impl From> for Quiz<'_> { fn from(output: QuizGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl Collection for Quiz<'_> { const NSID: &'static str = "pub.quizzy.quiz"; type Record = QuizRecord; } impl Collection for QuizRecord { const NSID: &'static str = "pub.quizzy.quiz"; type Record = QuizRecord; } impl<'a> LexiconSchema for Quiz<'a> { fn nsid() -> &'static str { "pub.quizzy.quiz" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_pub_quizzy_quiz() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 300usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("description"), max: 300usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.description { { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 3000usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("description"), max: 3000usize, actual: count, }); } } } { let value = &self.locales; #[allow(unused_comparisons)] if value.len() > 10usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("locales"), max: 10usize, actual: value.len(), }); } } { let value = &self.locales; #[allow(unused_comparisons)] if value.len() < 1usize { return Err(ConstraintError::MinLength { path: ValidationPath::from_field("locales"), min: 1usize, actual: value.len(), }); } } { let value = &self.rounds; #[allow(unused_comparisons)] if value.len() > 50usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("rounds"), max: 50usize, actual: value.len(), }); } } { let value = &self.rounds; #[allow(unused_comparisons)] if value.len() < 1usize { return Err(ConstraintError::MinLength { path: ValidationPath::from_field("rounds"), min: 1usize, actual: value.len(), }); } } Ok(()) } } impl<'a> LexiconSchema for QuestionRef<'a> { fn nsid() -> &'static str { "pub.quizzy.quiz" } fn def_name() -> &'static str { "questionRef" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_pub_quizzy_quiz() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.name { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 16usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("name"), max: 16usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.name { { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 160usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("name"), max: 160usize, actual: count, }); } } } if let Some(ref value) = self.points { if *value < 1i64 { return Err(ConstraintError::Minimum { path: ValidationPath::from_field("points"), min: 1i64, actual: *value, }); } } Ok(()) } } impl<'a> LexiconSchema for Round<'a> { fn nsid() -> &'static str { "pub.quizzy.quiz" } fn def_name() -> &'static str { "round" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_pub_quizzy_quiz() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.questions; #[allow(unused_comparisons)] if value.len() > 100usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("questions"), max: 100usize, actual: value.len(), }); } } { let value = &self.questions; #[allow(unused_comparisons)] if value.len() < 1usize { return Err(ConstraintError::MinLength { path: ValidationPath::from_field("questions"), min: 1usize, actual: value.len(), }); } } if let Some(ref value) = self.title { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 1000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("title"), max: 1000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.title { { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 100usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("title"), max: 100usize, actual: count, }); } } } Ok(()) } } fn _default_quiz_has_audio() -> Option { Some(false) } fn _default_quiz_has_visuals() -> Option { Some(false) } pub mod quiz_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Locales; type Title; type Timestamp; type Rounds; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Locales = Unset; type Title = Unset; type Timestamp = Unset; type Rounds = Unset; } ///State transition - sets the `locales` field to Set pub struct SetLocales(PhantomData S>); impl sealed::Sealed for SetLocales {} impl State for SetLocales { type Locales = Set; type Title = S::Title; type Timestamp = S::Timestamp; type Rounds = S::Rounds; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData S>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { type Locales = S::Locales; type Title = Set; type Timestamp = S::Timestamp; type Rounds = S::Rounds; } ///State transition - sets the `timestamp` field to Set pub struct SetTimestamp(PhantomData S>); impl sealed::Sealed for SetTimestamp {} impl State for SetTimestamp { type Locales = S::Locales; type Title = S::Title; type Timestamp = Set; type Rounds = S::Rounds; } ///State transition - sets the `rounds` field to Set pub struct SetRounds(PhantomData S>); impl sealed::Sealed for SetRounds {} impl State for SetRounds { type Locales = S::Locales; type Title = S::Title; type Timestamp = S::Timestamp; type Rounds = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `locales` field pub struct locales(()); ///Marker type for the `title` field pub struct title(()); ///Marker type for the `timestamp` field pub struct timestamp(()); ///Marker type for the `rounds` field pub struct rounds(()); } } /// Builder for constructing an instance of this type pub struct QuizBuilder<'a, S: quiz_state::State> { _state: PhantomData S>, _fields: ( Option>, Option, Option, Option>, Option>, Option>>, Option, Option>, ), _lifetime: PhantomData<&'a ()>, } impl<'a> Quiz<'a> { /// Create a new builder for this type pub fn new() -> QuizBuilder<'a, quiz_state::Empty> { QuizBuilder::new() } } impl<'a> QuizBuilder<'a, quiz_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { QuizBuilder { _state: PhantomData, _fields: (None, None, None, None, None, None, None, None), _lifetime: PhantomData, } } } impl<'a, S: quiz_state::State> QuizBuilder<'a, S> { /// Set the `description` field (optional) pub fn description(mut self, value: impl Into>>) -> Self { self._fields.0 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description(mut self, value: Option>) -> Self { self._fields.0 = value; self } } impl<'a, S: quiz_state::State> QuizBuilder<'a, S> { /// Set the `hasAudio` field (optional) pub fn has_audio(mut self, value: impl Into>) -> Self { self._fields.1 = value.into(); self } /// Set the `hasAudio` field to an Option value (optional) pub fn maybe_has_audio(mut self, value: Option) -> Self { self._fields.1 = value; self } } impl<'a, S: quiz_state::State> QuizBuilder<'a, S> { /// Set the `hasVisuals` field (optional) pub fn has_visuals(mut self, value: impl Into>) -> Self { self._fields.2 = value.into(); self } /// Set the `hasVisuals` field to an Option value (optional) pub fn maybe_has_visuals(mut self, value: Option) -> Self { self._fields.2 = value; self } } impl<'a, S> QuizBuilder<'a, S> where S: quiz_state::State, S::Locales: quiz_state::IsUnset, { /// Set the `locales` field (required) pub fn locales( mut self, value: impl Into>, ) -> QuizBuilder<'a, quiz_state::SetLocales> { self._fields.3 = Option::Some(value.into()); QuizBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S: quiz_state::State> QuizBuilder<'a, S> { /// Set the `revisionOf` field (optional) pub fn revision_of(mut self, value: impl Into>>) -> Self { self._fields.4 = value.into(); self } /// Set the `revisionOf` field to an Option value (optional) pub fn maybe_revision_of(mut self, value: Option>) -> Self { self._fields.4 = value; self } } impl<'a, S> QuizBuilder<'a, S> where S: quiz_state::State, S::Rounds: quiz_state::IsUnset, { /// Set the `rounds` field (required) pub fn rounds( mut self, value: impl Into>>, ) -> QuizBuilder<'a, quiz_state::SetRounds> { self._fields.5 = Option::Some(value.into()); QuizBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S> QuizBuilder<'a, S> where S: quiz_state::State, S::Timestamp: quiz_state::IsUnset, { /// Set the `timestamp` field (required) pub fn timestamp( mut self, value: impl Into, ) -> QuizBuilder<'a, quiz_state::SetTimestamp> { self._fields.6 = Option::Some(value.into()); QuizBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S> QuizBuilder<'a, S> where S: quiz_state::State, S::Title: quiz_state::IsUnset, { /// Set the `title` field (required) pub fn title( mut self, value: impl Into>, ) -> QuizBuilder<'a, quiz_state::SetTitle> { self._fields.7 = Option::Some(value.into()); QuizBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S> QuizBuilder<'a, S> where S: quiz_state::State, S::Locales: quiz_state::IsSet, S::Title: quiz_state::IsSet, S::Timestamp: quiz_state::IsSet, S::Rounds: quiz_state::IsSet, { /// Build the final struct pub fn build(self) -> Quiz<'a> { Quiz { description: self._fields.0, has_audio: self._fields.1.or_else(|| Some(false)), has_visuals: self._fields.2.or_else(|| Some(false)), locales: self._fields.3.unwrap(), revision_of: self._fields.4, rounds: self._fields.5.unwrap(), timestamp: self._fields.6.unwrap(), title: self._fields.7.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Quiz<'a> { Quiz { description: self._fields.0, has_audio: self._fields.1.or_else(|| Some(false)), has_visuals: self._fields.2.or_else(|| Some(false)), locales: self._fields.3.unwrap(), revision_of: self._fields.4, rounds: self._fields.5.unwrap(), timestamp: self._fields.6.unwrap(), title: self._fields.7.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_pub_quizzy_quiz() -> 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("pub.quizzy.quiz"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("main"), LexUserType::Record(LexRecord { description: Some( CowStr::new_static( "A quiz containing one or more rounds of questions", ), ), key: Some(CowStr::new_static("tid")), record: LexRecordRecord::Object(LexObject { required: Some( vec![ SmolStr::new_static("title"), SmolStr::new_static("rounds"), SmolStr::new_static("locales"), SmolStr::new_static("timestamp") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("description"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "A short description about the quiz, and what to expect from it", ), ), max_length: Some(300usize), max_graphemes: Some(3000usize), ..Default::default() }), ); map.insert( SmolStr::new_static("hasAudio"), LexObjectProperty::Boolean(LexBoolean { ..Default::default() }), ); map.insert( SmolStr::new_static("hasVisuals"), LexObjectProperty::Boolean(LexBoolean { ..Default::default() }), ); map.insert( SmolStr::new_static("locales"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static("Dominant language(s) of the quiz"), ), items: LexArrayItem::String(LexString { format: Some(LexStringFormat::Language), ..Default::default() }), min_length: Some(1usize), max_length: Some(10usize), ..Default::default() }), ); map.insert( SmolStr::new_static("revisionOf"), LexObjectProperty::Ref(LexRef { r#ref: CowStr::new_static("com.atproto.repo.strongRef"), ..Default::default() }), ); map.insert( SmolStr::new_static("rounds"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static("Ordered list of rounds in this quiz"), ), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("#round"), ..Default::default() }), min_length: Some(1usize), max_length: Some(50usize), ..Default::default() }), ); map.insert( SmolStr::new_static("timestamp"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("When this quiz was created"), ), format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("title"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("A title for the quiz"), ), ..Default::default() }), ); map }, ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("questionRef"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "Reference to a question with its point value", ), ), required: Some(vec![SmolStr::new_static("question")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("name"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "A custom name for this question, as opposed to its number", ), ), max_length: Some(16usize), max_graphemes: Some(160usize), ..Default::default() }), ); map.insert( SmolStr::new_static("points"), LexObjectProperty::Integer(LexInteger { minimum: Some(1i64), ..Default::default() }), ); map.insert( SmolStr::new_static("question"), LexObjectProperty::Ref(LexRef { r#ref: CowStr::new_static("com.atproto.repo.strongRef"), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("round"), LexUserType::Object(LexObject { description: Some(CowStr::new_static("A round within a quiz")), required: Some(vec![SmolStr::new_static("questions")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("questions"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static( "Ordered list of questions in this round", ), ), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("#questionRef"), ..Default::default() }), min_length: Some(1usize), max_length: Some(100usize), ..Default::default() }), ); map.insert( SmolStr::new_static("title"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "Optional title for this round (requires locale if set)", ), ), max_length: Some(1000usize), max_graphemes: Some(100usize), ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() } } fn _default_question_ref_points() -> Option { Some(1i64) } pub mod question_ref_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Question; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Question = Unset; } ///State transition - sets the `question` field to Set pub struct SetQuestion(PhantomData S>); impl sealed::Sealed for SetQuestion {} impl State for SetQuestion { type Question = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `question` field pub struct question(()); } } /// Builder for constructing an instance of this type pub struct QuestionRefBuilder<'a, S: question_ref_state::State> { _state: PhantomData S>, _fields: (Option>, Option, Option>), _lifetime: PhantomData<&'a ()>, } impl<'a> QuestionRef<'a> { /// Create a new builder for this type pub fn new() -> QuestionRefBuilder<'a, question_ref_state::Empty> { QuestionRefBuilder::new() } } impl<'a> QuestionRefBuilder<'a, question_ref_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { QuestionRefBuilder { _state: PhantomData, _fields: (None, None, None), _lifetime: PhantomData, } } } impl<'a, S: question_ref_state::State> QuestionRefBuilder<'a, S> { /// Set the `name` field (optional) pub fn name(mut self, value: impl Into>>) -> Self { self._fields.0 = value.into(); self } /// Set the `name` field to an Option value (optional) pub fn maybe_name(mut self, value: Option>) -> Self { self._fields.0 = value; self } } impl<'a, S: question_ref_state::State> QuestionRefBuilder<'a, S> { /// Set the `points` field (optional) pub fn points(mut self, value: impl Into>) -> Self { self._fields.1 = value.into(); self } /// Set the `points` field to an Option value (optional) pub fn maybe_points(mut self, value: Option) -> Self { self._fields.1 = value; self } } impl<'a, S> QuestionRefBuilder<'a, S> where S: question_ref_state::State, S::Question: question_ref_state::IsUnset, { /// Set the `question` field (required) pub fn question( mut self, value: impl Into>, ) -> QuestionRefBuilder<'a, question_ref_state::SetQuestion> { self._fields.2 = Option::Some(value.into()); QuestionRefBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S> QuestionRefBuilder<'a, S> where S: question_ref_state::State, S::Question: question_ref_state::IsSet, { /// Build the final struct pub fn build(self) -> QuestionRef<'a> { QuestionRef { name: self._fields.0, points: self._fields.1.or_else(|| Some(1i64)), question: self._fields.2.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> QuestionRef<'a> { QuestionRef { name: self._fields.0, points: self._fields.1.or_else(|| Some(1i64)), question: self._fields.2.unwrap(), extra_data: Some(extra_data), } } } pub mod round_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Questions; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Questions = Unset; } ///State transition - sets the `questions` field to Set pub struct SetQuestions(PhantomData S>); impl sealed::Sealed for SetQuestions {} impl State for SetQuestions { type Questions = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `questions` field pub struct questions(()); } } /// Builder for constructing an instance of this type pub struct RoundBuilder<'a, S: round_state::State> { _state: PhantomData S>, _fields: (Option>>, Option>), _lifetime: PhantomData<&'a ()>, } impl<'a> Round<'a> { /// Create a new builder for this type pub fn new() -> RoundBuilder<'a, round_state::Empty> { RoundBuilder::new() } } impl<'a> RoundBuilder<'a, round_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { RoundBuilder { _state: PhantomData, _fields: (None, None), _lifetime: PhantomData, } } } impl<'a, S> RoundBuilder<'a, S> where S: round_state::State, S::Questions: round_state::IsUnset, { /// Set the `questions` field (required) pub fn questions( mut self, value: impl Into>>, ) -> RoundBuilder<'a, round_state::SetQuestions> { self._fields.0 = Option::Some(value.into()); RoundBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S: round_state::State> RoundBuilder<'a, S> { /// Set the `title` field (optional) pub fn title(mut self, value: impl Into>>) -> Self { self._fields.1 = value.into(); self } /// Set the `title` field to an Option value (optional) pub fn maybe_title(mut self, value: Option>) -> Self { self._fields.1 = value; self } } impl<'a, S> RoundBuilder<'a, S> where S: round_state::State, S::Questions: round_state::IsSet, { /// Build the final struct pub fn build(self) -> Round<'a> { Round { questions: self._fields.0.unwrap(), title: self._fields.1, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Round<'a> { Round { questions: self._fields.0.unwrap(), title: self._fields.1, extra_data: Some(extra_data), } } }