// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: org.devcon.event.test // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Test<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] pub created_at: std::option::Option, /// Description of the event #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub description: std::option::Option>, /// End time of the event pub end: jacquard_common::types::string::Datetime, /// Location of the event #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub location: std::option::Option>, /// Start time of the event pub start: jacquard_common::types::string::Datetime, /// Title of the event #[serde(borrow)] pub title: jacquard_common::CowStr<'a>, /// URL of the event #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub url: std::option::Option>, } pub mod test_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 Title; type End; type Start; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Title = Unset; type End = Unset; type Start = Unset; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData S>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { type Title = Set; type End = S::End; type Start = S::Start; } ///State transition - sets the `end` field to Set pub struct SetEnd(PhantomData S>); impl sealed::Sealed for SetEnd {} impl State for SetEnd { type Title = S::Title; type End = Set; type Start = S::Start; } ///State transition - sets the `start` field to Set pub struct SetStart(PhantomData S>); impl sealed::Sealed for SetStart {} impl State for SetStart { type Title = S::Title; type End = S::End; type Start = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `title` field pub struct title(()); ///Marker type for the `end` field pub struct end(()); ///Marker type for the `start` field pub struct start(()); } } /// Builder for constructing an instance of this type pub struct TestBuilder<'a, S: test_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option, ::core::option::Option>, ::core::option::Option, ::core::option::Option>, ::core::option::Option, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Test<'a> { /// Create a new builder for this type pub fn new() -> TestBuilder<'a, test_state::Empty> { TestBuilder::new() } } impl<'a> TestBuilder<'a, test_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { TestBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: test_state::State> TestBuilder<'a, S> { /// Set the `createdAt` field (optional) pub fn created_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `createdAt` field to an Option value (optional) pub fn maybe_created_at( mut self, value: Option, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S: test_state::State> TestBuilder<'a, S> { /// Set the `description` field (optional) pub fn description( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S> TestBuilder<'a, S> where S: test_state::State, S::End: test_state::IsUnset, { /// Set the `end` field (required) pub fn end( mut self, value: impl Into, ) -> TestBuilder<'a, test_state::SetEnd> { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); TestBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: test_state::State> TestBuilder<'a, S> { /// Set the `location` field (optional) pub fn location( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `location` field to an Option value (optional) pub fn maybe_location(mut self, value: Option>) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S> TestBuilder<'a, S> where S: test_state::State, S::Start: test_state::IsUnset, { /// Set the `start` field (required) pub fn start( mut self, value: impl Into, ) -> TestBuilder<'a, test_state::SetStart> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); TestBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> TestBuilder<'a, S> where S: test_state::State, S::Title: test_state::IsUnset, { /// Set the `title` field (required) pub fn title( mut self, value: impl Into>, ) -> TestBuilder<'a, test_state::SetTitle> { self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); TestBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: test_state::State> TestBuilder<'a, S> { /// Set the `url` field (optional) pub fn url(mut self, value: impl Into>>) -> Self { self.__unsafe_private_named.6 = value.into(); self } /// Set the `url` field to an Option value (optional) pub fn maybe_url(mut self, value: Option>) -> Self { self.__unsafe_private_named.6 = value; self } } impl<'a, S> TestBuilder<'a, S> where S: test_state::State, S::Title: test_state::IsSet, S::End: test_state::IsSet, S::Start: test_state::IsSet, { /// Build the final struct pub fn build(self) -> Test<'a> { Test { created_at: self.__unsafe_private_named.0, description: self.__unsafe_private_named.1, end: self.__unsafe_private_named.2.unwrap(), location: self.__unsafe_private_named.3, start: self.__unsafe_private_named.4.unwrap(), title: self.__unsafe_private_named.5.unwrap(), url: self.__unsafe_private_named.6, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Test<'a> { Test { created_at: self.__unsafe_private_named.0, description: self.__unsafe_private_named.1, end: self.__unsafe_private_named.2.unwrap(), location: self.__unsafe_private_named.3, start: self.__unsafe_private_named.4.unwrap(), title: self.__unsafe_private_named.5.unwrap(), url: self.__unsafe_private_named.6, extra_data: Some(extra_data), } } } impl<'a> Test<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, TestRecord>, jacquard_common::types::uri::UriError, > { jacquard_common::types::uri::RecordUri::try_from_uri( jacquard_common::types::string::AtUri::new_cow(uri.into())?, ) } } /// Typed wrapper for GetRecord response with this collection's record type. #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct TestGetRecordOutput<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub cid: std::option::Option>, #[serde(borrow)] pub uri: jacquard_common::types::string::AtUri<'a>, #[serde(borrow)] pub value: Test<'a>, } impl From> for Test<'_> { fn from(output: TestGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Test<'_> { const NSID: &'static str = "org.devcon.event.test"; type Record = TestRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct TestRecord; impl jacquard_common::xrpc::XrpcResp for TestRecord { const NSID: &'static str = "org.devcon.event.test"; const ENCODING: &'static str = "application/json"; type Output<'de> = TestGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for TestRecord { const NSID: &'static str = "org.devcon.event.test"; type Record = TestRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Test<'a> { fn nsid() -> &'static str { "org.devcon.event.test" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_org_devcon_event_test() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } fn lexicon_doc_org_devcon_event_test() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("org.devcon.event.test"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { description: None, 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::smol_str::SmolStr::new_static("title"), ::jacquard_common::smol_str::SmolStr::new_static("start"), ::jacquard_common::smol_str::SmolStr::new_static("end") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::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::smol_str::SmolStr::new_static( "description", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Description of the event", ), ), format: None, 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::smol_str::SmolStr::new_static("end"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "End time of the event", ), ), 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::smol_str::SmolStr::new_static( "location", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Location of the event", ), ), format: None, 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::smol_str::SmolStr::new_static("start"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Start time of the event", ), ), 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::smol_str::SmolStr::new_static("title"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static("Title of the event"), ), format: None, 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::smol_str::SmolStr::new_static("url"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static("URL of the event"), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), }), ); map }, } }