···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// This file was automatically generated from Lexicon schemas.
44+// Any manual changes will be overwritten on the next regeneration.
55+66+/// Marker type indicating a builder field has been set
77+pub struct Set<T>(pub T);
88+impl<T> Set<T> {
99+ /// Extract the inner value
1010+ #[inline]
1111+ pub fn into_inner(self) -> T {
1212+ self.0
1313+ }
1414+}
1515+1616+/// Marker type indicating a builder field has not been set
1717+pub struct Unset;
1818+/// Trait indicating a builder field is set (has a value)
1919+#[rustversion::attr(
2020+ since(1.78.0),
2121+ diagnostic::on_unimplemented(
2222+ message = "the field `{Self}` was not set, but this method requires it to be set",
2323+ label = "the field `{Self}` was not set"
2424+ )
2525+)]
2626+pub trait IsSet: private::Sealed {}
2727+/// Trait indicating a builder field is unset (no value yet)
2828+#[rustversion::attr(
2929+ since(1.78.0),
3030+ diagnostic::on_unimplemented(
3131+ message = "the field `{Self}` was already set, but this method requires it to be unset",
3232+ label = "the field `{Self}` was already set"
3333+ )
3434+)]
3535+pub trait IsUnset: private::Sealed {}
3636+impl<T> IsSet for Set<T> {}
3737+impl IsUnset for Unset {}
3838+mod private {
3939+ /// Sealed trait to prevent external implementations
4040+ pub trait Sealed {}
4141+ impl<T> Sealed for super::Set<T> {}
4242+ impl Sealed for super::Unset {}
4343+}
+6
lexicons-example/src/com_atproto.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// This file was automatically generated from Lexicon schemas.
44+// Any manual changes will be overwritten on the next regeneration.
55+66+pub mod repo;
+6
lexicons-example/src/com_atproto/repo.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// This file was automatically generated from Lexicon schemas.
44+// Any manual changes will be overwritten on the next regeneration.
55+66+pub mod strong_ref;
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// Lexicon: com.atproto.repo.strongRef
44+//
55+// This file was automatically generated from Lexicon schemas.
66+// Any manual changes will be overwritten on the next regeneration.
77+88+#[jacquard_derive::lexicon]
99+#[derive(
1010+ serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic,
1111+)]
1212+#[serde(rename_all = "camelCase")]
1313+pub struct StrongRef<'a> {
1414+ #[serde(borrow)]
1515+ pub cid: jacquard_common::types::string::Cid<'a>,
1616+ #[serde(borrow)]
1717+ pub uri: jacquard_common::types::string::AtUri<'a>,
1818+}
1919+2020+pub mod strong_ref_state {
2121+2222+ pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
2323+ #[allow(unused)]
2424+ use ::core::marker::PhantomData;
2525+ mod sealed {
2626+ pub trait Sealed {}
2727+ }
2828+ /// State trait tracking which required fields have been set
2929+ pub trait State: sealed::Sealed {
3030+ type Uri;
3131+ type Cid;
3232+ }
3333+ /// Empty state - all required fields are unset
3434+ pub struct Empty(());
3535+ impl sealed::Sealed for Empty {}
3636+ impl State for Empty {
3737+ type Uri = Unset;
3838+ type Cid = Unset;
3939+ }
4040+ ///State transition - sets the `uri` field to Set
4141+ pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
4242+ impl<S: State> sealed::Sealed for SetUri<S> {}
4343+ impl<S: State> State for SetUri<S> {
4444+ type Uri = Set<members::uri>;
4545+ type Cid = S::Cid;
4646+ }
4747+ ///State transition - sets the `cid` field to Set
4848+ pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
4949+ impl<S: State> sealed::Sealed for SetCid<S> {}
5050+ impl<S: State> State for SetCid<S> {
5151+ type Uri = S::Uri;
5252+ type Cid = Set<members::cid>;
5353+ }
5454+ /// Marker types for field names
5555+ #[allow(non_camel_case_types)]
5656+ pub mod members {
5757+ ///Marker type for the `uri` field
5858+ pub struct uri(());
5959+ ///Marker type for the `cid` field
6060+ pub struct cid(());
6161+ }
6262+}
6363+6464+/// Builder for constructing an instance of this type
6565+pub struct StrongRefBuilder<'a, S: strong_ref_state::State> {
6666+ _phantom_state: ::core::marker::PhantomData<fn() -> S>,
6767+ __unsafe_private_named: (
6868+ ::core::option::Option<jacquard_common::types::string::Cid<'a>>,
6969+ ::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
7070+ ),
7171+ _phantom: ::core::marker::PhantomData<&'a ()>,
7272+}
7373+7474+impl<'a> StrongRef<'a> {
7575+ /// Create a new builder for this type
7676+ pub fn new() -> StrongRefBuilder<'a, strong_ref_state::Empty> {
7777+ StrongRefBuilder::new()
7878+ }
7979+}
8080+8181+impl<'a> StrongRefBuilder<'a, strong_ref_state::Empty> {
8282+ /// Create a new builder with all fields unset
8383+ pub fn new() -> Self {
8484+ StrongRefBuilder {
8585+ _phantom_state: ::core::marker::PhantomData,
8686+ __unsafe_private_named: (None, None),
8787+ _phantom: ::core::marker::PhantomData,
8888+ }
8989+ }
9090+}
9191+9292+impl<'a, S> StrongRefBuilder<'a, S>
9393+where
9494+ S: strong_ref_state::State,
9595+ S::Cid: strong_ref_state::IsUnset,
9696+{
9797+ /// Set the `cid` field (required)
9898+ pub fn cid(
9999+ mut self,
100100+ value: impl Into<jacquard_common::types::string::Cid<'a>>,
101101+ ) -> StrongRefBuilder<'a, strong_ref_state::SetCid<S>> {
102102+ self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
103103+ StrongRefBuilder {
104104+ _phantom_state: ::core::marker::PhantomData,
105105+ __unsafe_private_named: self.__unsafe_private_named,
106106+ _phantom: ::core::marker::PhantomData,
107107+ }
108108+ }
109109+}
110110+111111+impl<'a, S> StrongRefBuilder<'a, S>
112112+where
113113+ S: strong_ref_state::State,
114114+ S::Uri: strong_ref_state::IsUnset,
115115+{
116116+ /// Set the `uri` field (required)
117117+ pub fn uri(
118118+ mut self,
119119+ value: impl Into<jacquard_common::types::string::AtUri<'a>>,
120120+ ) -> StrongRefBuilder<'a, strong_ref_state::SetUri<S>> {
121121+ self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
122122+ StrongRefBuilder {
123123+ _phantom_state: ::core::marker::PhantomData,
124124+ __unsafe_private_named: self.__unsafe_private_named,
125125+ _phantom: ::core::marker::PhantomData,
126126+ }
127127+ }
128128+}
129129+130130+impl<'a, S> StrongRefBuilder<'a, S>
131131+where
132132+ S: strong_ref_state::State,
133133+ S::Uri: strong_ref_state::IsSet,
134134+ S::Cid: strong_ref_state::IsSet,
135135+{
136136+ /// Build the final struct
137137+ pub fn build(self) -> StrongRef<'a> {
138138+ StrongRef {
139139+ cid: self.__unsafe_private_named.0.unwrap(),
140140+ uri: self.__unsafe_private_named.1.unwrap(),
141141+ extra_data: Default::default(),
142142+ }
143143+ }
144144+ /// Build the final struct with custom extra_data
145145+ pub fn build_with_data(
146146+ self,
147147+ extra_data: std::collections::BTreeMap<
148148+ jacquard_common::smol_str::SmolStr,
149149+ jacquard_common::types::value::Data<'a>,
150150+ >,
151151+ ) -> StrongRef<'a> {
152152+ StrongRef {
153153+ cid: self.__unsafe_private_named.0.unwrap(),
154154+ uri: self.__unsafe_private_named.1.unwrap(),
155155+ extra_data: Some(extra_data),
156156+ }
157157+ }
158158+}
159159+160160+fn lexicon_doc_com_atproto_repo_strongRef() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
161161+ ::jacquard_lexicon::lexicon::LexiconDoc {
162162+ lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
163163+ id: ::jacquard_common::CowStr::new_static("com.atproto.repo.strongRef"),
164164+ revision: None,
165165+ description: None,
166166+ defs: {
167167+ let mut map = ::std::collections::BTreeMap::new();
168168+ map.insert(
169169+ ::jacquard_common::smol_str::SmolStr::new_static("main"),
170170+ ::jacquard_lexicon::lexicon::LexUserType::Object(
171171+ ::jacquard_lexicon::lexicon::LexObject {
172172+ description: None,
173173+ required: Some(vec![
174174+ ::jacquard_common::smol_str::SmolStr::new_static("uri"),
175175+ ::jacquard_common::smol_str::SmolStr::new_static("cid"),
176176+ ]),
177177+ nullable: None,
178178+ properties: {
179179+ #[allow(unused_mut)]
180180+ let mut map = ::std::collections::BTreeMap::new();
181181+ map.insert(
182182+ ::jacquard_common::smol_str::SmolStr::new_static("cid"),
183183+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(
184184+ ::jacquard_lexicon::lexicon::LexString {
185185+ description: None,
186186+ format: Some(
187187+ ::jacquard_lexicon::lexicon::LexStringFormat::Cid,
188188+ ),
189189+ default: None,
190190+ min_length: None,
191191+ max_length: None,
192192+ min_graphemes: None,
193193+ max_graphemes: None,
194194+ r#enum: None,
195195+ r#const: None,
196196+ known_values: None,
197197+ },
198198+ ),
199199+ );
200200+ map.insert(
201201+ ::jacquard_common::smol_str::SmolStr::new_static("uri"),
202202+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(
203203+ ::jacquard_lexicon::lexicon::LexString {
204204+ description: None,
205205+ format: Some(
206206+ ::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
207207+ ),
208208+ default: None,
209209+ min_length: None,
210210+ max_length: None,
211211+ min_graphemes: None,
212212+ max_graphemes: None,
213213+ r#enum: None,
214214+ r#const: None,
215215+ known_values: None,
216216+ },
217217+ ),
218218+ );
219219+ map
220220+ },
221221+ },
222222+ ),
223223+ );
224224+ map
225225+ },
226226+ }
227227+}
228228+229229+impl<'a> ::jacquard_lexicon::schema::LexiconSchema for StrongRef<'a> {
230230+ fn nsid() -> &'static str {
231231+ "com.atproto.repo.strongRef"
232232+ }
233233+ fn def_name() -> &'static str {
234234+ "main"
235235+ }
236236+ fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
237237+ lexicon_doc_com_atproto_repo_strongRef()
238238+ }
239239+ fn validate(
240240+ &self,
241241+ ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
242242+ Ok(())
243243+ }
244244+}
+12
lexicons-example/src/lib.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// This file was automatically generated from Lexicon schemas.
44+// Any manual changes will be overwritten on the next regeneration.
55+66+pub mod builder_types;
77+88+#[cfg(feature = "com_atproto")]
99+pub mod com_atproto;
1010+1111+#[cfg(feature = "site_standard")]
1212+pub mod site_standard;
+9
lexicons-example/src/site_standard.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// This file was automatically generated from Lexicon schemas.
44+// Any manual changes will be overwritten on the next regeneration.
55+66+pub mod document;
77+pub mod graph;
88+pub mod publication;
99+pub mod theme;
+714
lexicons-example/src/site_standard/document.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// Lexicon: site.standard.document
44+//
55+// This file was automatically generated from Lexicon schemas.
66+// Any manual changes will be overwritten on the next regeneration.
77+88+#[jacquard_derive::lexicon]
99+#[derive(
1010+ serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic,
1111+)]
1212+#[serde(rename_all = "camelCase")]
1313+pub struct Document<'a> {
1414+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
1515+ #[serde(borrow)]
1616+ pub bsky_post_ref: std::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
1717+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
1818+ #[serde(borrow)]
1919+ pub content: std::option::Option<jacquard_common::types::value::Data<'a>>,
2020+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
2121+ #[serde(borrow)]
2222+ pub cover_image: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
2323+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
2424+ #[serde(borrow)]
2525+ pub description: std::option::Option<jacquard_common::CowStr<'a>>,
2626+ /// combine with the publication url or the document site to construct a full url to the document
2727+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
2828+ #[serde(borrow)]
2929+ pub path: std::option::Option<jacquard_common::CowStr<'a>>,
3030+ pub published_at: jacquard_common::types::string::Datetime,
3131+ /// URI to the site or publication this document belongs to (https or at-uri)
3232+ #[serde(borrow)]
3333+ pub site: jacquard_common::types::string::Uri<'a>,
3434+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
3535+ #[serde(borrow)]
3636+ pub tags: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
3737+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
3838+ #[serde(borrow)]
3939+ pub text_content: std::option::Option<jacquard_common::CowStr<'a>>,
4040+ #[serde(borrow)]
4141+ pub title: jacquard_common::CowStr<'a>,
4242+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
4343+ pub updated_at: std::option::Option<jacquard_common::types::string::Datetime>,
4444+}
4545+4646+pub mod document_state {
4747+4848+ pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
4949+ #[allow(unused)]
5050+ use ::core::marker::PhantomData;
5151+ mod sealed {
5252+ pub trait Sealed {}
5353+ }
5454+ /// State trait tracking which required fields have been set
5555+ pub trait State: sealed::Sealed {
5656+ type Title;
5757+ type Site;
5858+ type PublishedAt;
5959+ }
6060+ /// Empty state - all required fields are unset
6161+ pub struct Empty(());
6262+ impl sealed::Sealed for Empty {}
6363+ impl State for Empty {
6464+ type Title = Unset;
6565+ type Site = Unset;
6666+ type PublishedAt = Unset;
6767+ }
6868+ ///State transition - sets the `title` field to Set
6969+ pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
7070+ impl<S: State> sealed::Sealed for SetTitle<S> {}
7171+ impl<S: State> State for SetTitle<S> {
7272+ type Title = Set<members::title>;
7373+ type Site = S::Site;
7474+ type PublishedAt = S::PublishedAt;
7575+ }
7676+ ///State transition - sets the `site` field to Set
7777+ pub struct SetSite<S: State = Empty>(PhantomData<fn() -> S>);
7878+ impl<S: State> sealed::Sealed for SetSite<S> {}
7979+ impl<S: State> State for SetSite<S> {
8080+ type Title = S::Title;
8181+ type Site = Set<members::site>;
8282+ type PublishedAt = S::PublishedAt;
8383+ }
8484+ ///State transition - sets the `published_at` field to Set
8585+ pub struct SetPublishedAt<S: State = Empty>(PhantomData<fn() -> S>);
8686+ impl<S: State> sealed::Sealed for SetPublishedAt<S> {}
8787+ impl<S: State> State for SetPublishedAt<S> {
8888+ type Title = S::Title;
8989+ type Site = S::Site;
9090+ type PublishedAt = Set<members::published_at>;
9191+ }
9292+ /// Marker types for field names
9393+ #[allow(non_camel_case_types)]
9494+ pub mod members {
9595+ ///Marker type for the `title` field
9696+ pub struct title(());
9797+ ///Marker type for the `site` field
9898+ pub struct site(());
9999+ ///Marker type for the `published_at` field
100100+ pub struct published_at(());
101101+ }
102102+}
103103+104104+/// Builder for constructing an instance of this type
105105+pub struct DocumentBuilder<'a, S: document_state::State> {
106106+ _phantom_state: ::core::marker::PhantomData<fn() -> S>,
107107+ __unsafe_private_named: (
108108+ ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
109109+ ::core::option::Option<jacquard_common::types::value::Data<'a>>,
110110+ ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
111111+ ::core::option::Option<jacquard_common::CowStr<'a>>,
112112+ ::core::option::Option<jacquard_common::CowStr<'a>>,
113113+ ::core::option::Option<jacquard_common::types::string::Datetime>,
114114+ ::core::option::Option<jacquard_common::types::string::Uri<'a>>,
115115+ ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
116116+ ::core::option::Option<jacquard_common::CowStr<'a>>,
117117+ ::core::option::Option<jacquard_common::CowStr<'a>>,
118118+ ::core::option::Option<jacquard_common::types::string::Datetime>,
119119+ ),
120120+ _phantom: ::core::marker::PhantomData<&'a ()>,
121121+}
122122+123123+impl<'a> Document<'a> {
124124+ /// Create a new builder for this type
125125+ pub fn new() -> DocumentBuilder<'a, document_state::Empty> {
126126+ DocumentBuilder::new()
127127+ }
128128+}
129129+130130+impl<'a> DocumentBuilder<'a, document_state::Empty> {
131131+ /// Create a new builder with all fields unset
132132+ pub fn new() -> Self {
133133+ DocumentBuilder {
134134+ _phantom_state: ::core::marker::PhantomData,
135135+ __unsafe_private_named: (
136136+ None, None, None, None, None, None, None, None, None, None, None,
137137+ ),
138138+ _phantom: ::core::marker::PhantomData,
139139+ }
140140+ }
141141+}
142142+143143+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
144144+ /// Set the `bskyPostRef` field (optional)
145145+ pub fn bsky_post_ref(
146146+ mut self,
147147+ value: impl Into<Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
148148+ ) -> Self {
149149+ self.__unsafe_private_named.0 = value.into();
150150+ self
151151+ }
152152+ /// Set the `bskyPostRef` field to an Option value (optional)
153153+ pub fn maybe_bsky_post_ref(
154154+ mut self,
155155+ value: Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
156156+ ) -> Self {
157157+ self.__unsafe_private_named.0 = value;
158158+ self
159159+ }
160160+}
161161+162162+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
163163+ /// Set the `content` field (optional)
164164+ pub fn content(
165165+ mut self,
166166+ value: impl Into<Option<jacquard_common::types::value::Data<'a>>>,
167167+ ) -> Self {
168168+ self.__unsafe_private_named.1 = value.into();
169169+ self
170170+ }
171171+ /// Set the `content` field to an Option value (optional)
172172+ pub fn maybe_content(mut self, value: Option<jacquard_common::types::value::Data<'a>>) -> Self {
173173+ self.__unsafe_private_named.1 = value;
174174+ self
175175+ }
176176+}
177177+178178+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
179179+ /// Set the `coverImage` field (optional)
180180+ pub fn cover_image(
181181+ mut self,
182182+ value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
183183+ ) -> Self {
184184+ self.__unsafe_private_named.2 = value.into();
185185+ self
186186+ }
187187+ /// Set the `coverImage` field to an Option value (optional)
188188+ pub fn maybe_cover_image(
189189+ mut self,
190190+ value: Option<jacquard_common::types::blob::BlobRef<'a>>,
191191+ ) -> Self {
192192+ self.__unsafe_private_named.2 = value;
193193+ self
194194+ }
195195+}
196196+197197+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
198198+ /// Set the `description` field (optional)
199199+ pub fn description(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
200200+ self.__unsafe_private_named.3 = value.into();
201201+ self
202202+ }
203203+ /// Set the `description` field to an Option value (optional)
204204+ pub fn maybe_description(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
205205+ self.__unsafe_private_named.3 = value;
206206+ self
207207+ }
208208+}
209209+210210+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
211211+ /// Set the `path` field (optional)
212212+ pub fn path(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
213213+ self.__unsafe_private_named.4 = value.into();
214214+ self
215215+ }
216216+ /// Set the `path` field to an Option value (optional)
217217+ pub fn maybe_path(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
218218+ self.__unsafe_private_named.4 = value;
219219+ self
220220+ }
221221+}
222222+223223+impl<'a, S> DocumentBuilder<'a, S>
224224+where
225225+ S: document_state::State,
226226+ S::PublishedAt: document_state::IsUnset,
227227+{
228228+ /// Set the `publishedAt` field (required)
229229+ pub fn published_at(
230230+ mut self,
231231+ value: impl Into<jacquard_common::types::string::Datetime>,
232232+ ) -> DocumentBuilder<'a, document_state::SetPublishedAt<S>> {
233233+ self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
234234+ DocumentBuilder {
235235+ _phantom_state: ::core::marker::PhantomData,
236236+ __unsafe_private_named: self.__unsafe_private_named,
237237+ _phantom: ::core::marker::PhantomData,
238238+ }
239239+ }
240240+}
241241+242242+impl<'a, S> DocumentBuilder<'a, S>
243243+where
244244+ S: document_state::State,
245245+ S::Site: document_state::IsUnset,
246246+{
247247+ /// Set the `site` field (required)
248248+ pub fn site(
249249+ mut self,
250250+ value: impl Into<jacquard_common::types::string::Uri<'a>>,
251251+ ) -> DocumentBuilder<'a, document_state::SetSite<S>> {
252252+ self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
253253+ DocumentBuilder {
254254+ _phantom_state: ::core::marker::PhantomData,
255255+ __unsafe_private_named: self.__unsafe_private_named,
256256+ _phantom: ::core::marker::PhantomData,
257257+ }
258258+ }
259259+}
260260+261261+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
262262+ /// Set the `tags` field (optional)
263263+ pub fn tags(mut self, value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>) -> Self {
264264+ self.__unsafe_private_named.7 = value.into();
265265+ self
266266+ }
267267+ /// Set the `tags` field to an Option value (optional)
268268+ pub fn maybe_tags(mut self, value: Option<Vec<jacquard_common::CowStr<'a>>>) -> Self {
269269+ self.__unsafe_private_named.7 = value;
270270+ self
271271+ }
272272+}
273273+274274+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
275275+ /// Set the `textContent` field (optional)
276276+ pub fn text_content(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
277277+ self.__unsafe_private_named.8 = value.into();
278278+ self
279279+ }
280280+ /// Set the `textContent` field to an Option value (optional)
281281+ pub fn maybe_text_content(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
282282+ self.__unsafe_private_named.8 = value;
283283+ self
284284+ }
285285+}
286286+287287+impl<'a, S> DocumentBuilder<'a, S>
288288+where
289289+ S: document_state::State,
290290+ S::Title: document_state::IsUnset,
291291+{
292292+ /// Set the `title` field (required)
293293+ pub fn title(
294294+ mut self,
295295+ value: impl Into<jacquard_common::CowStr<'a>>,
296296+ ) -> DocumentBuilder<'a, document_state::SetTitle<S>> {
297297+ self.__unsafe_private_named.9 = ::core::option::Option::Some(value.into());
298298+ DocumentBuilder {
299299+ _phantom_state: ::core::marker::PhantomData,
300300+ __unsafe_private_named: self.__unsafe_private_named,
301301+ _phantom: ::core::marker::PhantomData,
302302+ }
303303+ }
304304+}
305305+306306+impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
307307+ /// Set the `updatedAt` field (optional)
308308+ pub fn updated_at(
309309+ mut self,
310310+ value: impl Into<Option<jacquard_common::types::string::Datetime>>,
311311+ ) -> Self {
312312+ self.__unsafe_private_named.10 = value.into();
313313+ self
314314+ }
315315+ /// Set the `updatedAt` field to an Option value (optional)
316316+ pub fn maybe_updated_at(
317317+ mut self,
318318+ value: Option<jacquard_common::types::string::Datetime>,
319319+ ) -> Self {
320320+ self.__unsafe_private_named.10 = value;
321321+ self
322322+ }
323323+}
324324+325325+impl<'a, S> DocumentBuilder<'a, S>
326326+where
327327+ S: document_state::State,
328328+ S::Title: document_state::IsSet,
329329+ S::Site: document_state::IsSet,
330330+ S::PublishedAt: document_state::IsSet,
331331+{
332332+ /// Build the final struct
333333+ pub fn build(self) -> Document<'a> {
334334+ Document {
335335+ bsky_post_ref: self.__unsafe_private_named.0,
336336+ content: self.__unsafe_private_named.1,
337337+ cover_image: self.__unsafe_private_named.2,
338338+ description: self.__unsafe_private_named.3,
339339+ path: self.__unsafe_private_named.4,
340340+ published_at: self.__unsafe_private_named.5.unwrap(),
341341+ site: self.__unsafe_private_named.6.unwrap(),
342342+ tags: self.__unsafe_private_named.7,
343343+ text_content: self.__unsafe_private_named.8,
344344+ title: self.__unsafe_private_named.9.unwrap(),
345345+ updated_at: self.__unsafe_private_named.10,
346346+ extra_data: Default::default(),
347347+ }
348348+ }
349349+ /// Build the final struct with custom extra_data
350350+ pub fn build_with_data(
351351+ self,
352352+ extra_data: std::collections::BTreeMap<
353353+ jacquard_common::smol_str::SmolStr,
354354+ jacquard_common::types::value::Data<'a>,
355355+ >,
356356+ ) -> Document<'a> {
357357+ Document {
358358+ bsky_post_ref: self.__unsafe_private_named.0,
359359+ content: self.__unsafe_private_named.1,
360360+ cover_image: self.__unsafe_private_named.2,
361361+ description: self.__unsafe_private_named.3,
362362+ path: self.__unsafe_private_named.4,
363363+ published_at: self.__unsafe_private_named.5.unwrap(),
364364+ site: self.__unsafe_private_named.6.unwrap(),
365365+ tags: self.__unsafe_private_named.7,
366366+ text_content: self.__unsafe_private_named.8,
367367+ title: self.__unsafe_private_named.9.unwrap(),
368368+ updated_at: self.__unsafe_private_named.10,
369369+ extra_data: Some(extra_data),
370370+ }
371371+ }
372372+}
373373+374374+impl<'a> Document<'a> {
375375+ pub fn uri(
376376+ uri: impl Into<jacquard_common::CowStr<'a>>,
377377+ ) -> Result<
378378+ jacquard_common::types::uri::RecordUri<'a, DocumentRecord>,
379379+ jacquard_common::types::uri::UriError,
380380+ > {
381381+ jacquard_common::types::uri::RecordUri::try_from_uri(
382382+ jacquard_common::types::string::AtUri::new_cow(uri.into())?,
383383+ )
384384+ }
385385+}
386386+387387+/// Typed wrapper for GetRecord response with this collection's record type.
388388+#[derive(
389389+ serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic,
390390+)]
391391+#[serde(rename_all = "camelCase")]
392392+pub struct DocumentGetRecordOutput<'a> {
393393+ #[serde(skip_serializing_if = "std::option::Option::is_none")]
394394+ #[serde(borrow)]
395395+ pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
396396+ #[serde(borrow)]
397397+ pub uri: jacquard_common::types::string::AtUri<'a>,
398398+ #[serde(borrow)]
399399+ pub value: Document<'a>,
400400+}
401401+402402+impl From<DocumentGetRecordOutput<'_>> for Document<'_> {
403403+ fn from(output: DocumentGetRecordOutput<'_>) -> Self {
404404+ use jacquard_common::IntoStatic;
405405+ output.value.into_static()
406406+ }
407407+}
408408+409409+impl jacquard_common::types::collection::Collection for Document<'_> {
410410+ const NSID: &'static str = "site.standard.document";
411411+ type Record = DocumentRecord;
412412+}
413413+414414+/// Marker type for deserializing records from this collection.
415415+#[derive(Debug, serde::Serialize, serde::Deserialize)]
416416+pub struct DocumentRecord;
417417+impl jacquard_common::xrpc::XrpcResp for DocumentRecord {
418418+ const NSID: &'static str = "site.standard.document";
419419+ const ENCODING: &'static str = "application/json";
420420+ type Output<'de> = DocumentGetRecordOutput<'de>;
421421+ type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
422422+}
423423+424424+impl jacquard_common::types::collection::Collection for DocumentRecord {
425425+ const NSID: &'static str = "site.standard.document";
426426+ type Record = DocumentRecord;
427427+}
428428+429429+impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Document<'a> {
430430+ fn nsid() -> &'static str {
431431+ "site.standard.document"
432432+ }
433433+ fn def_name() -> &'static str {
434434+ "main"
435435+ }
436436+ fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
437437+ lexicon_doc_site_standard_document()
438438+ }
439439+ fn validate(
440440+ &self,
441441+ ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
442442+ if let Some(ref value) = self.description {
443443+ #[allow(unused_comparisons)]
444444+ if <str>::len(value.as_ref()) > 3000usize {
445445+ return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
446446+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("description"),
447447+ max: 3000usize,
448448+ actual: <str>::len(value.as_ref()),
449449+ });
450450+ }
451451+ }
452452+ if let Some(ref value) = self.description {
453453+ {
454454+ let count =
455455+ ::unicode_segmentation::UnicodeSegmentation::graphemes(value.as_ref(), true)
456456+ .count();
457457+ if count > 300usize {
458458+ return Err(
459459+ ::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
460460+ path: ::jacquard_lexicon::validation::ValidationPath::from_field(
461461+ "description",
462462+ ),
463463+ max: 300usize,
464464+ actual: count,
465465+ },
466466+ );
467467+ }
468468+ }
469469+ }
470470+ {
471471+ let value = &self.title;
472472+ #[allow(unused_comparisons)]
473473+ if <str>::len(value.as_ref()) > 1280usize {
474474+ return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
475475+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("title"),
476476+ max: 1280usize,
477477+ actual: <str>::len(value.as_ref()),
478478+ });
479479+ }
480480+ }
481481+ {
482482+ let value = &self.title;
483483+ {
484484+ let count =
485485+ ::unicode_segmentation::UnicodeSegmentation::graphemes(value.as_ref(), true)
486486+ .count();
487487+ if count > 128usize {
488488+ return Err(
489489+ ::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
490490+ path: ::jacquard_lexicon::validation::ValidationPath::from_field(
491491+ "title",
492492+ ),
493493+ max: 128usize,
494494+ actual: count,
495495+ },
496496+ );
497497+ }
498498+ }
499499+ }
500500+ Ok(())
501501+ }
502502+}
503503+504504+fn lexicon_doc_site_standard_document() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
505505+ ::jacquard_lexicon::lexicon::LexiconDoc {
506506+ lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
507507+ id: ::jacquard_common::CowStr::new_static("site.standard.document"),
508508+ revision: None,
509509+ description: None,
510510+ defs: {
511511+ let mut map = ::std::collections::BTreeMap::new();
512512+ map.insert(
513513+ ::jacquard_common::smol_str::SmolStr::new_static("main"),
514514+ ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
515515+ description: None,
516516+ key: Some(::jacquard_common::CowStr::new_static("tid")),
517517+ record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
518518+ description: None,
519519+ required: Some(
520520+ vec![
521521+ ::jacquard_common::smol_str::SmolStr::new_static("site"),
522522+ ::jacquard_common::smol_str::SmolStr::new_static("title"),
523523+ ::jacquard_common::smol_str::SmolStr::new_static("publishedAt")
524524+ ],
525525+ ),
526526+ nullable: None,
527527+ properties: {
528528+ #[allow(unused_mut)]
529529+ let mut map = ::std::collections::BTreeMap::new();
530530+ map.insert(
531531+ ::jacquard_common::smol_str::SmolStr::new_static(
532532+ "bskyPostRef",
533533+ ),
534534+ ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
535535+ description: None,
536536+ r#ref: ::jacquard_common::CowStr::new_static(
537537+ "com.atproto.repo.strongRef",
538538+ ),
539539+ }),
540540+ );
541541+ map.insert(
542542+ ::jacquard_common::smol_str::SmolStr::new_static("content"),
543543+ ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
544544+ description: None,
545545+ refs: vec![],
546546+ closed: Some(false),
547547+ }),
548548+ );
549549+ map.insert(
550550+ ::jacquard_common::smol_str::SmolStr::new_static(
551551+ "coverImage",
552552+ ),
553553+ ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
554554+ description: None,
555555+ accept: None,
556556+ max_size: None,
557557+ }),
558558+ );
559559+ map.insert(
560560+ ::jacquard_common::smol_str::SmolStr::new_static(
561561+ "description",
562562+ ),
563563+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
564564+ description: None,
565565+ format: None,
566566+ default: None,
567567+ min_length: None,
568568+ max_length: Some(3000usize),
569569+ min_graphemes: None,
570570+ max_graphemes: Some(300usize),
571571+ r#enum: None,
572572+ r#const: None,
573573+ known_values: None,
574574+ }),
575575+ );
576576+ map.insert(
577577+ ::jacquard_common::smol_str::SmolStr::new_static("path"),
578578+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
579579+ description: Some(
580580+ ::jacquard_common::CowStr::new_static(
581581+ "combine with the publication url or the document site to construct a full url to the document",
582582+ ),
583583+ ),
584584+ format: None,
585585+ default: None,
586586+ min_length: None,
587587+ max_length: None,
588588+ min_graphemes: None,
589589+ max_graphemes: None,
590590+ r#enum: None,
591591+ r#const: None,
592592+ known_values: None,
593593+ }),
594594+ );
595595+ map.insert(
596596+ ::jacquard_common::smol_str::SmolStr::new_static(
597597+ "publishedAt",
598598+ ),
599599+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
600600+ description: None,
601601+ format: Some(
602602+ ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
603603+ ),
604604+ default: None,
605605+ min_length: None,
606606+ max_length: None,
607607+ min_graphemes: None,
608608+ max_graphemes: None,
609609+ r#enum: None,
610610+ r#const: None,
611611+ known_values: None,
612612+ }),
613613+ );
614614+ map.insert(
615615+ ::jacquard_common::smol_str::SmolStr::new_static("site"),
616616+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
617617+ description: Some(
618618+ ::jacquard_common::CowStr::new_static(
619619+ "URI to the site or publication this document belongs to (https or at-uri)",
620620+ ),
621621+ ),
622622+ format: Some(
623623+ ::jacquard_lexicon::lexicon::LexStringFormat::Uri,
624624+ ),
625625+ default: None,
626626+ min_length: None,
627627+ max_length: None,
628628+ min_graphemes: None,
629629+ max_graphemes: None,
630630+ r#enum: None,
631631+ r#const: None,
632632+ known_values: None,
633633+ }),
634634+ );
635635+ map.insert(
636636+ ::jacquard_common::smol_str::SmolStr::new_static("tags"),
637637+ ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
638638+ description: None,
639639+ items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
640640+ description: None,
641641+ format: None,
642642+ default: None,
643643+ min_length: None,
644644+ max_length: Some(100usize),
645645+ min_graphemes: None,
646646+ max_graphemes: Some(50usize),
647647+ r#enum: None,
648648+ r#const: None,
649649+ known_values: None,
650650+ }),
651651+ min_length: None,
652652+ max_length: None,
653653+ }),
654654+ );
655655+ map.insert(
656656+ ::jacquard_common::smol_str::SmolStr::new_static(
657657+ "textContent",
658658+ ),
659659+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
660660+ description: None,
661661+ format: None,
662662+ default: None,
663663+ min_length: None,
664664+ max_length: None,
665665+ min_graphemes: None,
666666+ max_graphemes: None,
667667+ r#enum: None,
668668+ r#const: None,
669669+ known_values: None,
670670+ }),
671671+ );
672672+ map.insert(
673673+ ::jacquard_common::smol_str::SmolStr::new_static("title"),
674674+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
675675+ description: None,
676676+ format: None,
677677+ default: None,
678678+ min_length: None,
679679+ max_length: Some(1280usize),
680680+ min_graphemes: None,
681681+ max_graphemes: Some(128usize),
682682+ r#enum: None,
683683+ r#const: None,
684684+ known_values: None,
685685+ }),
686686+ );
687687+ map.insert(
688688+ ::jacquard_common::smol_str::SmolStr::new_static(
689689+ "updatedAt",
690690+ ),
691691+ ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
692692+ description: None,
693693+ format: Some(
694694+ ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
695695+ ),
696696+ default: None,
697697+ min_length: None,
698698+ max_length: None,
699699+ min_graphemes: None,
700700+ max_graphemes: None,
701701+ r#enum: None,
702702+ r#const: None,
703703+ known_values: None,
704704+ }),
705705+ );
706706+ map
707707+ },
708708+ }),
709709+ }),
710710+ );
711711+ map
712712+ },
713713+ }
714714+}
+6
lexicons-example/src/site_standard/graph.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// This file was automatically generated from Lexicon schemas.
44+// Any manual changes will be overwritten on the next regeneration.
55+66+pub mod subscription;
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// This file was automatically generated from Lexicon schemas.
44+// Any manual changes will be overwritten on the next regeneration.
55+66+pub mod basic;
77+pub mod color;
+359
lexicons-example/src/site_standard/theme/basic.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// Lexicon: site.standard.theme.basic
44+//
55+// This file was automatically generated from Lexicon schemas.
66+// Any manual changes will be overwritten on the next regeneration.
77+88+/// A simplified theme definition for publications, providing basic color customization for content display across different platforms and applications.
99+#[jacquard_derive::lexicon]
1010+#[derive(
1111+ serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic,
1212+)]
1313+#[serde(rename_all = "camelCase")]
1414+pub struct Basic<'a> {
1515+ /// Color used for links and button backgrounds.
1616+ #[serde(borrow)]
1717+ pub accent: crate::site_standard::theme::color::Rgb<'a>,
1818+ /// Color used for button text.
1919+ #[serde(borrow)]
2020+ pub accent_foreground: crate::site_standard::theme::color::Rgb<'a>,
2121+ /// Color used for content background.
2222+ #[serde(borrow)]
2323+ pub background: crate::site_standard::theme::color::Rgb<'a>,
2424+ /// Color used for content text.
2525+ #[serde(borrow)]
2626+ pub foreground: crate::site_standard::theme::color::Rgb<'a>,
2727+}
2828+2929+pub mod basic_state {
3030+3131+ pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
3232+ #[allow(unused)]
3333+ use ::core::marker::PhantomData;
3434+ mod sealed {
3535+ pub trait Sealed {}
3636+ }
3737+ /// State trait tracking which required fields have been set
3838+ pub trait State: sealed::Sealed {
3939+ type Background;
4040+ type AccentForeground;
4141+ type Accent;
4242+ type Foreground;
4343+ }
4444+ /// Empty state - all required fields are unset
4545+ pub struct Empty(());
4646+ impl sealed::Sealed for Empty {}
4747+ impl State for Empty {
4848+ type Background = Unset;
4949+ type AccentForeground = Unset;
5050+ type Accent = Unset;
5151+ type Foreground = Unset;
5252+ }
5353+ ///State transition - sets the `background` field to Set
5454+ pub struct SetBackground<S: State = Empty>(PhantomData<fn() -> S>);
5555+ impl<S: State> sealed::Sealed for SetBackground<S> {}
5656+ impl<S: State> State for SetBackground<S> {
5757+ type Background = Set<members::background>;
5858+ type AccentForeground = S::AccentForeground;
5959+ type Accent = S::Accent;
6060+ type Foreground = S::Foreground;
6161+ }
6262+ ///State transition - sets the `accent_foreground` field to Set
6363+ pub struct SetAccentForeground<S: State = Empty>(PhantomData<fn() -> S>);
6464+ impl<S: State> sealed::Sealed for SetAccentForeground<S> {}
6565+ impl<S: State> State for SetAccentForeground<S> {
6666+ type Background = S::Background;
6767+ type AccentForeground = Set<members::accent_foreground>;
6868+ type Accent = S::Accent;
6969+ type Foreground = S::Foreground;
7070+ }
7171+ ///State transition - sets the `accent` field to Set
7272+ pub struct SetAccent<S: State = Empty>(PhantomData<fn() -> S>);
7373+ impl<S: State> sealed::Sealed for SetAccent<S> {}
7474+ impl<S: State> State for SetAccent<S> {
7575+ type Background = S::Background;
7676+ type AccentForeground = S::AccentForeground;
7777+ type Accent = Set<members::accent>;
7878+ type Foreground = S::Foreground;
7979+ }
8080+ ///State transition - sets the `foreground` field to Set
8181+ pub struct SetForeground<S: State = Empty>(PhantomData<fn() -> S>);
8282+ impl<S: State> sealed::Sealed for SetForeground<S> {}
8383+ impl<S: State> State for SetForeground<S> {
8484+ type Background = S::Background;
8585+ type AccentForeground = S::AccentForeground;
8686+ type Accent = S::Accent;
8787+ type Foreground = Set<members::foreground>;
8888+ }
8989+ /// Marker types for field names
9090+ #[allow(non_camel_case_types)]
9191+ pub mod members {
9292+ ///Marker type for the `background` field
9393+ pub struct background(());
9494+ ///Marker type for the `accent_foreground` field
9595+ pub struct accent_foreground(());
9696+ ///Marker type for the `accent` field
9797+ pub struct accent(());
9898+ ///Marker type for the `foreground` field
9999+ pub struct foreground(());
100100+ }
101101+}
102102+103103+/// Builder for constructing an instance of this type
104104+pub struct BasicBuilder<'a, S: basic_state::State> {
105105+ _phantom_state: ::core::marker::PhantomData<fn() -> S>,
106106+ __unsafe_private_named: (
107107+ ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>,
108108+ ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>,
109109+ ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>,
110110+ ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>,
111111+ ),
112112+ _phantom: ::core::marker::PhantomData<&'a ()>,
113113+}
114114+115115+impl<'a> Basic<'a> {
116116+ /// Create a new builder for this type
117117+ pub fn new() -> BasicBuilder<'a, basic_state::Empty> {
118118+ BasicBuilder::new()
119119+ }
120120+}
121121+122122+impl<'a> BasicBuilder<'a, basic_state::Empty> {
123123+ /// Create a new builder with all fields unset
124124+ pub fn new() -> Self {
125125+ BasicBuilder {
126126+ _phantom_state: ::core::marker::PhantomData,
127127+ __unsafe_private_named: (None, None, None, None),
128128+ _phantom: ::core::marker::PhantomData,
129129+ }
130130+ }
131131+}
132132+133133+impl<'a, S> BasicBuilder<'a, S>
134134+where
135135+ S: basic_state::State,
136136+ S::Accent: basic_state::IsUnset,
137137+{
138138+ /// Set the `accent` field (required)
139139+ pub fn accent(
140140+ mut self,
141141+ value: impl Into<crate::site_standard::theme::color::Rgb<'a>>,
142142+ ) -> BasicBuilder<'a, basic_state::SetAccent<S>> {
143143+ self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
144144+ BasicBuilder {
145145+ _phantom_state: ::core::marker::PhantomData,
146146+ __unsafe_private_named: self.__unsafe_private_named,
147147+ _phantom: ::core::marker::PhantomData,
148148+ }
149149+ }
150150+}
151151+152152+impl<'a, S> BasicBuilder<'a, S>
153153+where
154154+ S: basic_state::State,
155155+ S::AccentForeground: basic_state::IsUnset,
156156+{
157157+ /// Set the `accentForeground` field (required)
158158+ pub fn accent_foreground(
159159+ mut self,
160160+ value: impl Into<crate::site_standard::theme::color::Rgb<'a>>,
161161+ ) -> BasicBuilder<'a, basic_state::SetAccentForeground<S>> {
162162+ self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
163163+ BasicBuilder {
164164+ _phantom_state: ::core::marker::PhantomData,
165165+ __unsafe_private_named: self.__unsafe_private_named,
166166+ _phantom: ::core::marker::PhantomData,
167167+ }
168168+ }
169169+}
170170+171171+impl<'a, S> BasicBuilder<'a, S>
172172+where
173173+ S: basic_state::State,
174174+ S::Background: basic_state::IsUnset,
175175+{
176176+ /// Set the `background` field (required)
177177+ pub fn background(
178178+ mut self,
179179+ value: impl Into<crate::site_standard::theme::color::Rgb<'a>>,
180180+ ) -> BasicBuilder<'a, basic_state::SetBackground<S>> {
181181+ self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
182182+ BasicBuilder {
183183+ _phantom_state: ::core::marker::PhantomData,
184184+ __unsafe_private_named: self.__unsafe_private_named,
185185+ _phantom: ::core::marker::PhantomData,
186186+ }
187187+ }
188188+}
189189+190190+impl<'a, S> BasicBuilder<'a, S>
191191+where
192192+ S: basic_state::State,
193193+ S::Foreground: basic_state::IsUnset,
194194+{
195195+ /// Set the `foreground` field (required)
196196+ pub fn foreground(
197197+ mut self,
198198+ value: impl Into<crate::site_standard::theme::color::Rgb<'a>>,
199199+ ) -> BasicBuilder<'a, basic_state::SetForeground<S>> {
200200+ self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
201201+ BasicBuilder {
202202+ _phantom_state: ::core::marker::PhantomData,
203203+ __unsafe_private_named: self.__unsafe_private_named,
204204+ _phantom: ::core::marker::PhantomData,
205205+ }
206206+ }
207207+}
208208+209209+impl<'a, S> BasicBuilder<'a, S>
210210+where
211211+ S: basic_state::State,
212212+ S::Background: basic_state::IsSet,
213213+ S::AccentForeground: basic_state::IsSet,
214214+ S::Accent: basic_state::IsSet,
215215+ S::Foreground: basic_state::IsSet,
216216+{
217217+ /// Build the final struct
218218+ pub fn build(self) -> Basic<'a> {
219219+ Basic {
220220+ accent: self.__unsafe_private_named.0.unwrap(),
221221+ accent_foreground: self.__unsafe_private_named.1.unwrap(),
222222+ background: self.__unsafe_private_named.2.unwrap(),
223223+ foreground: self.__unsafe_private_named.3.unwrap(),
224224+ extra_data: Default::default(),
225225+ }
226226+ }
227227+ /// Build the final struct with custom extra_data
228228+ pub fn build_with_data(
229229+ self,
230230+ extra_data: std::collections::BTreeMap<
231231+ jacquard_common::smol_str::SmolStr,
232232+ jacquard_common::types::value::Data<'a>,
233233+ >,
234234+ ) -> Basic<'a> {
235235+ Basic {
236236+ accent: self.__unsafe_private_named.0.unwrap(),
237237+ accent_foreground: self.__unsafe_private_named.1.unwrap(),
238238+ background: self.__unsafe_private_named.2.unwrap(),
239239+ foreground: self.__unsafe_private_named.3.unwrap(),
240240+ extra_data: Some(extra_data),
241241+ }
242242+ }
243243+}
244244+245245+fn lexicon_doc_site_standard_theme_basic() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
246246+ ::jacquard_lexicon::lexicon::LexiconDoc {
247247+ lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
248248+ id: ::jacquard_common::CowStr::new_static("site.standard.theme.basic"),
249249+ revision: None,
250250+ description: None,
251251+ defs: {
252252+ let mut map = ::std::collections::BTreeMap::new();
253253+ map.insert(
254254+ ::jacquard_common::smol_str::SmolStr::new_static("main"),
255255+ ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
256256+ description: Some(
257257+ ::jacquard_common::CowStr::new_static(
258258+ "A simplified theme definition for publications, providing basic color customization for content display across different platforms and applications.",
259259+ ),
260260+ ),
261261+ required: Some(
262262+ vec![
263263+ ::jacquard_common::smol_str::SmolStr::new_static("background"),
264264+ ::jacquard_common::smol_str::SmolStr::new_static("foreground"),
265265+ ::jacquard_common::smol_str::SmolStr::new_static("accent"),
266266+ ::jacquard_common::smol_str::SmolStr::new_static("accentForeground")
267267+ ],
268268+ ),
269269+ nullable: None,
270270+ properties: {
271271+ #[allow(unused_mut)]
272272+ let mut map = ::std::collections::BTreeMap::new();
273273+ map.insert(
274274+ ::jacquard_common::smol_str::SmolStr::new_static("accent"),
275275+ ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
276276+ description: Some(
277277+ ::jacquard_common::CowStr::new_static(
278278+ "Color used for links and button backgrounds.",
279279+ ),
280280+ ),
281281+ refs: vec![
282282+ ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb")
283283+ ],
284284+ closed: None,
285285+ }),
286286+ );
287287+ map.insert(
288288+ ::jacquard_common::smol_str::SmolStr::new_static(
289289+ "accentForeground",
290290+ ),
291291+ ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
292292+ description: Some(
293293+ ::jacquard_common::CowStr::new_static(
294294+ "Color used for button text.",
295295+ ),
296296+ ),
297297+ refs: vec![
298298+ ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb")
299299+ ],
300300+ closed: None,
301301+ }),
302302+ );
303303+ map.insert(
304304+ ::jacquard_common::smol_str::SmolStr::new_static(
305305+ "background",
306306+ ),
307307+ ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
308308+ description: Some(
309309+ ::jacquard_common::CowStr::new_static(
310310+ "Color used for content background.",
311311+ ),
312312+ ),
313313+ refs: vec![
314314+ ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb")
315315+ ],
316316+ closed: None,
317317+ }),
318318+ );
319319+ map.insert(
320320+ ::jacquard_common::smol_str::SmolStr::new_static(
321321+ "foreground",
322322+ ),
323323+ ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
324324+ description: Some(
325325+ ::jacquard_common::CowStr::new_static(
326326+ "Color used for content text.",
327327+ ),
328328+ ),
329329+ refs: vec![
330330+ ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb")
331331+ ],
332332+ closed: None,
333333+ }),
334334+ );
335335+ map
336336+ },
337337+ }),
338338+ );
339339+ map
340340+ },
341341+ }
342342+}
343343+344344+impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Basic<'a> {
345345+ fn nsid() -> &'static str {
346346+ "site.standard.theme.basic"
347347+ }
348348+ fn def_name() -> &'static str {
349349+ "main"
350350+ }
351351+ fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
352352+ lexicon_doc_site_standard_theme_basic()
353353+ }
354354+ fn validate(
355355+ &self,
356356+ ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
357357+ Ok(())
358358+ }
359359+}
+718
lexicons-example/src/site_standard/theme/color.rs
···11+// @generated by jacquard-lexicon. DO NOT EDIT.
22+//
33+// Lexicon: site.standard.theme.color
44+//
55+// This file was automatically generated from Lexicon schemas.
66+// Any manual changes will be overwritten on the next regeneration.
77+88+#[jacquard_derive::lexicon]
99+#[derive(
1010+ serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic,
1111+)]
1212+#[serde(rename_all = "camelCase")]
1313+pub struct Rgb<'a> {
1414+ pub b: i64,
1515+ pub g: i64,
1616+ pub r: i64,
1717+}
1818+1919+pub mod rgb_state {
2020+2121+ pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
2222+ #[allow(unused)]
2323+ use ::core::marker::PhantomData;
2424+ mod sealed {
2525+ pub trait Sealed {}
2626+ }
2727+ /// State trait tracking which required fields have been set
2828+ pub trait State: sealed::Sealed {
2929+ type B;
3030+ type R;
3131+ type G;
3232+ }
3333+ /// Empty state - all required fields are unset
3434+ pub struct Empty(());
3535+ impl sealed::Sealed for Empty {}
3636+ impl State for Empty {
3737+ type B = Unset;
3838+ type R = Unset;
3939+ type G = Unset;
4040+ }
4141+ ///State transition - sets the `b` field to Set
4242+ pub struct SetB<S: State = Empty>(PhantomData<fn() -> S>);
4343+ impl<S: State> sealed::Sealed for SetB<S> {}
4444+ impl<S: State> State for SetB<S> {
4545+ type B = Set<members::b>;
4646+ type R = S::R;
4747+ type G = S::G;
4848+ }
4949+ ///State transition - sets the `r` field to Set
5050+ pub struct SetR<S: State = Empty>(PhantomData<fn() -> S>);
5151+ impl<S: State> sealed::Sealed for SetR<S> {}
5252+ impl<S: State> State for SetR<S> {
5353+ type B = S::B;
5454+ type R = Set<members::r>;
5555+ type G = S::G;
5656+ }
5757+ ///State transition - sets the `g` field to Set
5858+ pub struct SetG<S: State = Empty>(PhantomData<fn() -> S>);
5959+ impl<S: State> sealed::Sealed for SetG<S> {}
6060+ impl<S: State> State for SetG<S> {
6161+ type B = S::B;
6262+ type R = S::R;
6363+ type G = Set<members::g>;
6464+ }
6565+ /// Marker types for field names
6666+ #[allow(non_camel_case_types)]
6767+ pub mod members {
6868+ ///Marker type for the `b` field
6969+ pub struct b(());
7070+ ///Marker type for the `r` field
7171+ pub struct r(());
7272+ ///Marker type for the `g` field
7373+ pub struct g(());
7474+ }
7575+}
7676+7777+/// Builder for constructing an instance of this type
7878+pub struct RgbBuilder<'a, S: rgb_state::State> {
7979+ _phantom_state: ::core::marker::PhantomData<fn() -> S>,
8080+ __unsafe_private_named: (
8181+ ::core::option::Option<i64>,
8282+ ::core::option::Option<i64>,
8383+ ::core::option::Option<i64>,
8484+ ),
8585+ _phantom: ::core::marker::PhantomData<&'a ()>,
8686+}
8787+8888+impl<'a> Rgb<'a> {
8989+ /// Create a new builder for this type
9090+ pub fn new() -> RgbBuilder<'a, rgb_state::Empty> {
9191+ RgbBuilder::new()
9292+ }
9393+}
9494+9595+impl<'a> RgbBuilder<'a, rgb_state::Empty> {
9696+ /// Create a new builder with all fields unset
9797+ pub fn new() -> Self {
9898+ RgbBuilder {
9999+ _phantom_state: ::core::marker::PhantomData,
100100+ __unsafe_private_named: (None, None, None),
101101+ _phantom: ::core::marker::PhantomData,
102102+ }
103103+ }
104104+}
105105+106106+impl<'a, S> RgbBuilder<'a, S>
107107+where
108108+ S: rgb_state::State,
109109+ S::B: rgb_state::IsUnset,
110110+{
111111+ /// Set the `b` field (required)
112112+ pub fn b(mut self, value: impl Into<i64>) -> RgbBuilder<'a, rgb_state::SetB<S>> {
113113+ self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
114114+ RgbBuilder {
115115+ _phantom_state: ::core::marker::PhantomData,
116116+ __unsafe_private_named: self.__unsafe_private_named,
117117+ _phantom: ::core::marker::PhantomData,
118118+ }
119119+ }
120120+}
121121+122122+impl<'a, S> RgbBuilder<'a, S>
123123+where
124124+ S: rgb_state::State,
125125+ S::G: rgb_state::IsUnset,
126126+{
127127+ /// Set the `g` field (required)
128128+ pub fn g(mut self, value: impl Into<i64>) -> RgbBuilder<'a, rgb_state::SetG<S>> {
129129+ self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
130130+ RgbBuilder {
131131+ _phantom_state: ::core::marker::PhantomData,
132132+ __unsafe_private_named: self.__unsafe_private_named,
133133+ _phantom: ::core::marker::PhantomData,
134134+ }
135135+ }
136136+}
137137+138138+impl<'a, S> RgbBuilder<'a, S>
139139+where
140140+ S: rgb_state::State,
141141+ S::R: rgb_state::IsUnset,
142142+{
143143+ /// Set the `r` field (required)
144144+ pub fn r(mut self, value: impl Into<i64>) -> RgbBuilder<'a, rgb_state::SetR<S>> {
145145+ self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
146146+ RgbBuilder {
147147+ _phantom_state: ::core::marker::PhantomData,
148148+ __unsafe_private_named: self.__unsafe_private_named,
149149+ _phantom: ::core::marker::PhantomData,
150150+ }
151151+ }
152152+}
153153+154154+impl<'a, S> RgbBuilder<'a, S>
155155+where
156156+ S: rgb_state::State,
157157+ S::B: rgb_state::IsSet,
158158+ S::R: rgb_state::IsSet,
159159+ S::G: rgb_state::IsSet,
160160+{
161161+ /// Build the final struct
162162+ pub fn build(self) -> Rgb<'a> {
163163+ Rgb {
164164+ b: self.__unsafe_private_named.0.unwrap(),
165165+ g: self.__unsafe_private_named.1.unwrap(),
166166+ r: self.__unsafe_private_named.2.unwrap(),
167167+ extra_data: Default::default(),
168168+ }
169169+ }
170170+ /// Build the final struct with custom extra_data
171171+ pub fn build_with_data(
172172+ self,
173173+ extra_data: std::collections::BTreeMap<
174174+ jacquard_common::smol_str::SmolStr,
175175+ jacquard_common::types::value::Data<'a>,
176176+ >,
177177+ ) -> Rgb<'a> {
178178+ Rgb {
179179+ b: self.__unsafe_private_named.0.unwrap(),
180180+ g: self.__unsafe_private_named.1.unwrap(),
181181+ r: self.__unsafe_private_named.2.unwrap(),
182182+ extra_data: Some(extra_data),
183183+ }
184184+ }
185185+}
186186+187187+fn lexicon_doc_site_standard_theme_color() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
188188+ ::jacquard_lexicon::lexicon::LexiconDoc {
189189+ lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
190190+ id: ::jacquard_common::CowStr::new_static("site.standard.theme.color"),
191191+ revision: None,
192192+ description: None,
193193+ defs: {
194194+ let mut map = ::std::collections::BTreeMap::new();
195195+ map.insert(
196196+ ::jacquard_common::smol_str::SmolStr::new_static("rgb"),
197197+ ::jacquard_lexicon::lexicon::LexUserType::Object(
198198+ ::jacquard_lexicon::lexicon::LexObject {
199199+ description: None,
200200+ required: Some(vec![
201201+ ::jacquard_common::smol_str::SmolStr::new_static("r"),
202202+ ::jacquard_common::smol_str::SmolStr::new_static("g"),
203203+ ::jacquard_common::smol_str::SmolStr::new_static("b"),
204204+ ]),
205205+ nullable: None,
206206+ properties: {
207207+ #[allow(unused_mut)]
208208+ let mut map = ::std::collections::BTreeMap::new();
209209+ map.insert(
210210+ ::jacquard_common::smol_str::SmolStr::new_static("b"),
211211+ ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(
212212+ ::jacquard_lexicon::lexicon::LexInteger {
213213+ description: None,
214214+ default: None,
215215+ minimum: Some(0i64),
216216+ maximum: Some(255i64),
217217+ r#enum: None,
218218+ r#const: None,
219219+ },
220220+ ),
221221+ );
222222+ map.insert(
223223+ ::jacquard_common::smol_str::SmolStr::new_static("g"),
224224+ ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(
225225+ ::jacquard_lexicon::lexicon::LexInteger {
226226+ description: None,
227227+ default: None,
228228+ minimum: Some(0i64),
229229+ maximum: Some(255i64),
230230+ r#enum: None,
231231+ r#const: None,
232232+ },
233233+ ),
234234+ );
235235+ map.insert(
236236+ ::jacquard_common::smol_str::SmolStr::new_static("r"),
237237+ ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(
238238+ ::jacquard_lexicon::lexicon::LexInteger {
239239+ description: None,
240240+ default: None,
241241+ minimum: Some(0i64),
242242+ maximum: Some(255i64),
243243+ r#enum: None,
244244+ r#const: None,
245245+ },
246246+ ),
247247+ );
248248+ map
249249+ },
250250+ },
251251+ ),
252252+ );
253253+ map.insert(
254254+ ::jacquard_common::smol_str::SmolStr::new_static("rgba"),
255255+ ::jacquard_lexicon::lexicon::LexUserType::Object(
256256+ ::jacquard_lexicon::lexicon::LexObject {
257257+ description: None,
258258+ required: Some(vec![
259259+ ::jacquard_common::smol_str::SmolStr::new_static("r"),
260260+ ::jacquard_common::smol_str::SmolStr::new_static("g"),
261261+ ::jacquard_common::smol_str::SmolStr::new_static("b"),
262262+ ::jacquard_common::smol_str::SmolStr::new_static("a"),
263263+ ]),
264264+ nullable: None,
265265+ properties: {
266266+ #[allow(unused_mut)]
267267+ let mut map = ::std::collections::BTreeMap::new();
268268+ map.insert(
269269+ ::jacquard_common::smol_str::SmolStr::new_static("a"),
270270+ ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(
271271+ ::jacquard_lexicon::lexicon::LexInteger {
272272+ description: None,
273273+ default: None,
274274+ minimum: Some(0i64),
275275+ maximum: Some(100i64),
276276+ r#enum: None,
277277+ r#const: None,
278278+ },
279279+ ),
280280+ );
281281+ map.insert(
282282+ ::jacquard_common::smol_str::SmolStr::new_static("b"),
283283+ ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(
284284+ ::jacquard_lexicon::lexicon::LexInteger {
285285+ description: None,
286286+ default: None,
287287+ minimum: Some(0i64),
288288+ maximum: Some(255i64),
289289+ r#enum: None,
290290+ r#const: None,
291291+ },
292292+ ),
293293+ );
294294+ map.insert(
295295+ ::jacquard_common::smol_str::SmolStr::new_static("g"),
296296+ ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(
297297+ ::jacquard_lexicon::lexicon::LexInteger {
298298+ description: None,
299299+ default: None,
300300+ minimum: Some(0i64),
301301+ maximum: Some(255i64),
302302+ r#enum: None,
303303+ r#const: None,
304304+ },
305305+ ),
306306+ );
307307+ map.insert(
308308+ ::jacquard_common::smol_str::SmolStr::new_static("r"),
309309+ ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(
310310+ ::jacquard_lexicon::lexicon::LexInteger {
311311+ description: None,
312312+ default: None,
313313+ minimum: Some(0i64),
314314+ maximum: Some(255i64),
315315+ r#enum: None,
316316+ r#const: None,
317317+ },
318318+ ),
319319+ );
320320+ map
321321+ },
322322+ },
323323+ ),
324324+ );
325325+ map
326326+ },
327327+ }
328328+}
329329+330330+impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Rgb<'a> {
331331+ fn nsid() -> &'static str {
332332+ "site.standard.theme.color"
333333+ }
334334+ fn def_name() -> &'static str {
335335+ "rgb"
336336+ }
337337+ fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
338338+ lexicon_doc_site_standard_theme_color()
339339+ }
340340+ fn validate(
341341+ &self,
342342+ ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
343343+ {
344344+ let value = &self.b;
345345+ if *value > 255i64 {
346346+ return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
347347+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("b"),
348348+ max: 255i64,
349349+ actual: *value,
350350+ });
351351+ }
352352+ }
353353+ {
354354+ let value = &self.b;
355355+ if *value < 0i64 {
356356+ return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
357357+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("b"),
358358+ min: 0i64,
359359+ actual: *value,
360360+ });
361361+ }
362362+ }
363363+ {
364364+ let value = &self.g;
365365+ if *value > 255i64 {
366366+ return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
367367+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("g"),
368368+ max: 255i64,
369369+ actual: *value,
370370+ });
371371+ }
372372+ }
373373+ {
374374+ let value = &self.g;
375375+ if *value < 0i64 {
376376+ return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
377377+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("g"),
378378+ min: 0i64,
379379+ actual: *value,
380380+ });
381381+ }
382382+ }
383383+ {
384384+ let value = &self.r;
385385+ if *value > 255i64 {
386386+ return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
387387+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("r"),
388388+ max: 255i64,
389389+ actual: *value,
390390+ });
391391+ }
392392+ }
393393+ {
394394+ let value = &self.r;
395395+ if *value < 0i64 {
396396+ return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
397397+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("r"),
398398+ min: 0i64,
399399+ actual: *value,
400400+ });
401401+ }
402402+ }
403403+ Ok(())
404404+ }
405405+}
406406+407407+#[jacquard_derive::lexicon]
408408+#[derive(
409409+ serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic,
410410+)]
411411+#[serde(rename_all = "camelCase")]
412412+pub struct Rgba<'a> {
413413+ pub a: i64,
414414+ pub b: i64,
415415+ pub g: i64,
416416+ pub r: i64,
417417+}
418418+419419+pub mod rgba_state {
420420+421421+ pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
422422+ #[allow(unused)]
423423+ use ::core::marker::PhantomData;
424424+ mod sealed {
425425+ pub trait Sealed {}
426426+ }
427427+ /// State trait tracking which required fields have been set
428428+ pub trait State: sealed::Sealed {
429429+ type A;
430430+ type R;
431431+ type B;
432432+ type G;
433433+ }
434434+ /// Empty state - all required fields are unset
435435+ pub struct Empty(());
436436+ impl sealed::Sealed for Empty {}
437437+ impl State for Empty {
438438+ type A = Unset;
439439+ type R = Unset;
440440+ type B = Unset;
441441+ type G = Unset;
442442+ }
443443+ ///State transition - sets the `a` field to Set
444444+ pub struct SetA<S: State = Empty>(PhantomData<fn() -> S>);
445445+ impl<S: State> sealed::Sealed for SetA<S> {}
446446+ impl<S: State> State for SetA<S> {
447447+ type A = Set<members::a>;
448448+ type R = S::R;
449449+ type B = S::B;
450450+ type G = S::G;
451451+ }
452452+ ///State transition - sets the `r` field to Set
453453+ pub struct SetR<S: State = Empty>(PhantomData<fn() -> S>);
454454+ impl<S: State> sealed::Sealed for SetR<S> {}
455455+ impl<S: State> State for SetR<S> {
456456+ type A = S::A;
457457+ type R = Set<members::r>;
458458+ type B = S::B;
459459+ type G = S::G;
460460+ }
461461+ ///State transition - sets the `b` field to Set
462462+ pub struct SetB<S: State = Empty>(PhantomData<fn() -> S>);
463463+ impl<S: State> sealed::Sealed for SetB<S> {}
464464+ impl<S: State> State for SetB<S> {
465465+ type A = S::A;
466466+ type R = S::R;
467467+ type B = Set<members::b>;
468468+ type G = S::G;
469469+ }
470470+ ///State transition - sets the `g` field to Set
471471+ pub struct SetG<S: State = Empty>(PhantomData<fn() -> S>);
472472+ impl<S: State> sealed::Sealed for SetG<S> {}
473473+ impl<S: State> State for SetG<S> {
474474+ type A = S::A;
475475+ type R = S::R;
476476+ type B = S::B;
477477+ type G = Set<members::g>;
478478+ }
479479+ /// Marker types for field names
480480+ #[allow(non_camel_case_types)]
481481+ pub mod members {
482482+ ///Marker type for the `a` field
483483+ pub struct a(());
484484+ ///Marker type for the `r` field
485485+ pub struct r(());
486486+ ///Marker type for the `b` field
487487+ pub struct b(());
488488+ ///Marker type for the `g` field
489489+ pub struct g(());
490490+ }
491491+}
492492+493493+/// Builder for constructing an instance of this type
494494+pub struct RgbaBuilder<'a, S: rgba_state::State> {
495495+ _phantom_state: ::core::marker::PhantomData<fn() -> S>,
496496+ __unsafe_private_named: (
497497+ ::core::option::Option<i64>,
498498+ ::core::option::Option<i64>,
499499+ ::core::option::Option<i64>,
500500+ ::core::option::Option<i64>,
501501+ ),
502502+ _phantom: ::core::marker::PhantomData<&'a ()>,
503503+}
504504+505505+impl<'a> Rgba<'a> {
506506+ /// Create a new builder for this type
507507+ pub fn new() -> RgbaBuilder<'a, rgba_state::Empty> {
508508+ RgbaBuilder::new()
509509+ }
510510+}
511511+512512+impl<'a> RgbaBuilder<'a, rgba_state::Empty> {
513513+ /// Create a new builder with all fields unset
514514+ pub fn new() -> Self {
515515+ RgbaBuilder {
516516+ _phantom_state: ::core::marker::PhantomData,
517517+ __unsafe_private_named: (None, None, None, None),
518518+ _phantom: ::core::marker::PhantomData,
519519+ }
520520+ }
521521+}
522522+523523+impl<'a, S> RgbaBuilder<'a, S>
524524+where
525525+ S: rgba_state::State,
526526+ S::A: rgba_state::IsUnset,
527527+{
528528+ /// Set the `a` field (required)
529529+ pub fn a(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetA<S>> {
530530+ self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
531531+ RgbaBuilder {
532532+ _phantom_state: ::core::marker::PhantomData,
533533+ __unsafe_private_named: self.__unsafe_private_named,
534534+ _phantom: ::core::marker::PhantomData,
535535+ }
536536+ }
537537+}
538538+539539+impl<'a, S> RgbaBuilder<'a, S>
540540+where
541541+ S: rgba_state::State,
542542+ S::B: rgba_state::IsUnset,
543543+{
544544+ /// Set the `b` field (required)
545545+ pub fn b(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetB<S>> {
546546+ self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
547547+ RgbaBuilder {
548548+ _phantom_state: ::core::marker::PhantomData,
549549+ __unsafe_private_named: self.__unsafe_private_named,
550550+ _phantom: ::core::marker::PhantomData,
551551+ }
552552+ }
553553+}
554554+555555+impl<'a, S> RgbaBuilder<'a, S>
556556+where
557557+ S: rgba_state::State,
558558+ S::G: rgba_state::IsUnset,
559559+{
560560+ /// Set the `g` field (required)
561561+ pub fn g(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetG<S>> {
562562+ self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
563563+ RgbaBuilder {
564564+ _phantom_state: ::core::marker::PhantomData,
565565+ __unsafe_private_named: self.__unsafe_private_named,
566566+ _phantom: ::core::marker::PhantomData,
567567+ }
568568+ }
569569+}
570570+571571+impl<'a, S> RgbaBuilder<'a, S>
572572+where
573573+ S: rgba_state::State,
574574+ S::R: rgba_state::IsUnset,
575575+{
576576+ /// Set the `r` field (required)
577577+ pub fn r(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetR<S>> {
578578+ self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
579579+ RgbaBuilder {
580580+ _phantom_state: ::core::marker::PhantomData,
581581+ __unsafe_private_named: self.__unsafe_private_named,
582582+ _phantom: ::core::marker::PhantomData,
583583+ }
584584+ }
585585+}
586586+587587+impl<'a, S> RgbaBuilder<'a, S>
588588+where
589589+ S: rgba_state::State,
590590+ S::A: rgba_state::IsSet,
591591+ S::R: rgba_state::IsSet,
592592+ S::B: rgba_state::IsSet,
593593+ S::G: rgba_state::IsSet,
594594+{
595595+ /// Build the final struct
596596+ pub fn build(self) -> Rgba<'a> {
597597+ Rgba {
598598+ a: self.__unsafe_private_named.0.unwrap(),
599599+ b: self.__unsafe_private_named.1.unwrap(),
600600+ g: self.__unsafe_private_named.2.unwrap(),
601601+ r: self.__unsafe_private_named.3.unwrap(),
602602+ extra_data: Default::default(),
603603+ }
604604+ }
605605+ /// Build the final struct with custom extra_data
606606+ pub fn build_with_data(
607607+ self,
608608+ extra_data: std::collections::BTreeMap<
609609+ jacquard_common::smol_str::SmolStr,
610610+ jacquard_common::types::value::Data<'a>,
611611+ >,
612612+ ) -> Rgba<'a> {
613613+ Rgba {
614614+ a: self.__unsafe_private_named.0.unwrap(),
615615+ b: self.__unsafe_private_named.1.unwrap(),
616616+ g: self.__unsafe_private_named.2.unwrap(),
617617+ r: self.__unsafe_private_named.3.unwrap(),
618618+ extra_data: Some(extra_data),
619619+ }
620620+ }
621621+}
622622+623623+impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Rgba<'a> {
624624+ fn nsid() -> &'static str {
625625+ "site.standard.theme.color"
626626+ }
627627+ fn def_name() -> &'static str {
628628+ "rgba"
629629+ }
630630+ fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
631631+ lexicon_doc_site_standard_theme_color()
632632+ }
633633+ fn validate(
634634+ &self,
635635+ ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
636636+ {
637637+ let value = &self.a;
638638+ if *value > 100i64 {
639639+ return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
640640+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("a"),
641641+ max: 100i64,
642642+ actual: *value,
643643+ });
644644+ }
645645+ }
646646+ {
647647+ let value = &self.a;
648648+ if *value < 0i64 {
649649+ return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
650650+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("a"),
651651+ min: 0i64,
652652+ actual: *value,
653653+ });
654654+ }
655655+ }
656656+ {
657657+ let value = &self.b;
658658+ if *value > 255i64 {
659659+ return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
660660+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("b"),
661661+ max: 255i64,
662662+ actual: *value,
663663+ });
664664+ }
665665+ }
666666+ {
667667+ let value = &self.b;
668668+ if *value < 0i64 {
669669+ return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
670670+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("b"),
671671+ min: 0i64,
672672+ actual: *value,
673673+ });
674674+ }
675675+ }
676676+ {
677677+ let value = &self.g;
678678+ if *value > 255i64 {
679679+ return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
680680+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("g"),
681681+ max: 255i64,
682682+ actual: *value,
683683+ });
684684+ }
685685+ }
686686+ {
687687+ let value = &self.g;
688688+ if *value < 0i64 {
689689+ return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
690690+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("g"),
691691+ min: 0i64,
692692+ actual: *value,
693693+ });
694694+ }
695695+ }
696696+ {
697697+ let value = &self.r;
698698+ if *value > 255i64 {
699699+ return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
700700+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("r"),
701701+ max: 255i64,
702702+ actual: *value,
703703+ });
704704+ }
705705+ }
706706+ {
707707+ let value = &self.r;
708708+ if *value < 0i64 {
709709+ return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
710710+ path: ::jacquard_lexicon::validation::ValidationPath::from_field("r"),
711711+ min: 0i64,
712712+ actual: *value,
713713+ });
714714+ }
715715+ }
716716+ Ok(())
717717+ }
718718+}
···350350 /// let mut receiver = client.channel().await?;
351351 ///
352352 /// while let Ok(event) = receiver.recv().await {
353353- /// println!("Event: {:?}", event);
354353 /// // Event is automatically acknowledged when dropped
355354 /// }
356355 /// # Ok(())
+1-1
src/config.rs
tapped/src/config.rs
···4242 pub max_db_conns: Option<u32>,
43434444 // Server
4545- /// HTTP server bind address (e.g., ":2480", "127.0.0.1:2480", or "[::1]:2480")
4545+ /// HTTP server bind address (e.g., `":2480"`, `"127.0.0.1:2480"`, or `"[::1]:2480"`)
4646 pub bind: Option<String>,
4747 /// Basic auth admin password for all requests
4848 pub admin_password: Option<String>,
+4
src/error.rs
tapped/src/error.rs
···6464 /// URL parse error
6565 #[error("URL parse error: {0}")]
6666 UrlParse(#[from] url::ParseError),
6767+6868+ /// No record present in event
6969+ #[error("No record present in event")]
7070+ NoRecordPresent,
6771}
+4-3
src/handle.rs
tapped/src/handle.rs
···1111/// A convenience type that owns both a tap process and its client.
1212///
1313/// `TapHandle` manages the lifecycle of a tap subprocess and provides
1414-/// access to a [`TapClient`] for interacting with it. When dropped,
1515-/// the process is gracefully shut down.
1414+/// access to a [`TapClient`] for interacting with it. The process receives
1515+/// SIGTERM when this handle is dropped. For graceful shutdown with timeout
1616+/// handling, call [`shutdown()`](TapHandle::shutdown) explicitly.
1617///
1718/// # Example
1819///
···3334///
3435/// let mut channel = handle.channel().await?;
3536/// while let Ok(event) = channel.recv().await {
3636-/// println!("Event: {:?}", event.event);
3737+/// // Handle event
3738/// }
3839///
3940/// Ok(())
+2-3
src/lib.rs
tapped/src/lib.rs
···3232//! // Stream events
3333//! let mut receiver = client.channel().await?;
3434//! while let Ok(event) = receiver.recv().await {
3535-//! println!("Received event: {:?}", event);
3635//! // Event is automatically acknowledged when dropped
3736//! }
3837//!
···5554pub use handle::TapHandle;
5655pub use process::TapProcess;
5756pub use types::{
5858- AccountStatus, Cursors, DidDocument, Event, IdentityEvent, Record, RecordAction, RecordEvent,
5959- RepoInfo, RepoState, Service, VerificationMethod,
5757+ AccountStatus, Cursors, DidDocument, Event, IdentityEvent, RecordAction, RecordEvent, RepoInfo,
5858+ RepoState, Service, VerificationMethod,
6059};
61606261/// A specialised Result type for tapped operations.
+2-1
src/process.rs
tapped/src/process.rs
···12121313/// A running tap process.
1414///
1515-/// The process is gracefully shut down when this struct is dropped.
1515+/// The process receives SIGTERM when this struct is dropped. For graceful
1616+/// shutdown with timeout handling, call [`shutdown()`](TapProcess::shutdown) explicitly.
1617pub struct TapProcess {
1718 child: Child,
1819 url: Url,
+84-94
src/types.rs
tapped/src/types.rs
···11//! Type definitions for tap events and API responses.
2233use serde::{Deserialize, Serialize};
44+use serde_json::value::RawValue;
4555-/// A record's JSON data with helper methods.
66-///
77-/// Wraps the raw JSON value and provides convenient accessors.
88-#[derive(Debug, Clone, Serialize, Deserialize)]
99-#[serde(transparent)]
1010-pub struct Record(serde_json::Value);
66+use tungstenite::protocol::frame::Utf8Bytes;
1171212-impl Record {
1313- /// Create a new Record from a JSON value.
1414- pub fn new(value: serde_json::Value) -> Self {
1515- Self(value)
1616- }
88+use crate::Error;
1791818- /// Access the raw JSON value.
1919- pub fn json(&self) -> &serde_json::Value {
2020- &self.0
2121- }
1010+self_cell::self_cell!(
1111+ pub(crate) struct Record {
1212+ owner: Utf8Bytes,
22132323- /// Consume and return the inner JSON value.
2424- pub fn into_json(self) -> serde_json::Value {
2525- self.0
1414+ #[covariant]
1515+ dependent: UnparsedRecord,
2616 }
1717+);
27182828- /// Returns the `$type` field (e.g., "app.bsky.feed.post").
2929- pub fn record_type(&self) -> Option<&str> {
3030- self.0.get("$type")?.as_str()
3131- }
3232-3333- /// Deserialize the record into a user-provided type.
3434- pub fn deserialize_as<T: serde::de::DeserializeOwned>(&self) -> crate::Result<T> {
3535- Ok(serde_json::from_value(self.0.clone())?)
3636- }
3737-}
1919+pub(crate) struct UnparsedRecord<'a>(pub(crate) Option<&'a RawValue>);
38203921/// Action performed on a record.
4022#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
···7456}
75577658/// A record event from the tap stream.
7777-#[derive(Debug, Clone)]
7859pub struct RecordEvent {
7960 /// Unique event ID for acknowledgment.
8061 pub id: u64,
···9374 /// CID of the record (None on delete).
9475 pub cid: Option<String>,
9576 /// The record data (None on delete).
9696- pub record: Option<Record>,
7777+ pub(crate) record: Option<Record>,
7878+}
7979+8080+impl RecordEvent {
8181+ /// Get the record's content as a reference to a JSON string
8282+ pub fn record_as_str(&self) -> Option<&str> {
8383+ self.record
8484+ .as_ref()
8585+ .and_then(|r| r.borrow_dependent().0)
8686+ .map(|rv| rv.get())
8787+ }
8888+8989+ /// Parse the record's content to a compatible struct
9090+ pub fn deserialize_as<T>(&self) -> Result<T, Error>
9191+ where
9292+ for<'de> T: Deserialize<'de>,
9393+ {
9494+ self.record_as_str()
9595+ .map_or(Err(Error::NoRecordPresent), |s| {
9696+ serde_json::from_str(s).map_err(Into::into)
9797+ })
9898+ }
9799}
9810099101/// An identity event from the tap stream.
···112114}
113115114116/// An event from the tap stream.
115115-#[derive(Debug, Clone)]
116117#[non_exhaustive]
117118pub enum Event {
118119 /// A record create/update/delete event.
···216217217218// Internal deserialisation structures for parsing tap's JSON format
218219219219-#[derive(Deserialize)]
220220-pub(crate) struct RawEvent {
221221- pub id: u64,
220220+#[derive(Deserialize, Clone)]
221221+#[serde(bound(deserialize = "'de: 'a"))]
222222+pub(crate) struct RawEvent<'a> {
223223+ #[serde(flatten)]
224224+ pub(crate) owned: RawEventOwned,
225225+ pub(crate) record: Option<RawRecordEvent<'a>>,
226226+}
227227+228228+#[derive(Deserialize, Clone)]
229229+pub(crate) struct RawEventOwned {
230230+ pub(crate) id: u64,
222231 #[serde(rename = "type")]
223223- pub type_: String,
224224- pub record: Option<RawRecordEvent>,
225225- pub identity: Option<RawIdentityEvent>,
232232+ pub(crate) type_: String,
233233+ pub(crate) identity: Option<RawIdentityEvent>,
226234}
227235228228-#[derive(Deserialize)]
229229-pub(crate) struct RawRecordEvent {
236236+#[derive(Deserialize, Clone)]
237237+#[serde(bound(deserialize = "'de: 'a"))]
238238+pub(crate) struct RawRecordEvent<'a> {
239239+ #[serde(flatten)]
240240+ pub owned: RawRecordEventOwned,
241241+ pub record: Option<&'a RawValue>,
242242+}
243243+244244+#[derive(Deserialize, Clone)]
245245+pub(crate) struct RawRecordEventOwned {
230246 pub live: bool,
231247 pub did: String,
232248 pub rev: String,
···234250 pub rkey: String,
235251 pub action: RecordAction,
236252 pub cid: Option<String>,
237237- pub record: Option<serde_json::Value>,
238253}
239254240240-#[derive(Deserialize)]
255255+#[derive(Deserialize, Clone)]
241256pub(crate) struct RawIdentityEvent {
242257 pub did: String,
243258 pub handle: String,
···246261 pub status: AccountStatus,
247262}
248263249249-impl RawEvent {
264264+impl RawEventOwned {
250265 /// Convert to the public Event type.
251251- pub fn into_event(self) -> Option<Event> {
266266+ pub fn into_event(
267267+ self,
268268+ raw_record: Option<RawRecordEventOwned>,
269269+ inner_record: Option<Record>,
270270+ ) -> Option<Event> {
252271 match self.type_.as_str() {
253272 "record" => {
254254- let r = self.record?;
273273+ let r = raw_record?;
255274 Some(Event::Record(RecordEvent {
256275 id: self.id,
257276 live: r.live,
···261280 rkey: r.rkey,
262281 action: r.action,
263282 cid: r.cid,
264264- record: r.record.map(Record::new),
283283+ record: inner_record,
265284 }))
266285 }
267286 "identity" => {
···311330 use super::*;
312331 use serde_json::json;
313332314314- #[test]
315315- fn record_type_extraction() {
316316- let record = Record::new(json!({
317317- "$type": "app.bsky.feed.post",
318318- "text": "Hello, world!",
319319- "createdAt": "2024-01-01T00:00:00Z"
320320- }));
321321-322322- assert_eq!(record.record_type(), Some("app.bsky.feed.post"));
323323- }
324324-325325- #[test]
326326- fn record_type_missing() {
327327- let record = Record::new(json!({
328328- "text": "No type field"
329329- }));
330330-331331- assert_eq!(record.record_type(), None);
332332- }
333333-334334- #[test]
335335- fn record_deserialize_as() {
336336- #[derive(Debug, Deserialize, PartialEq)]
337337- struct SimpleRecord {
338338- text: String,
339339- }
340340-341341- let record = Record::new(json!({
342342- "$type": "test.record",
343343- "text": "Hello!"
344344- }));
345345-346346- let parsed: SimpleRecord = record.deserialize_as().unwrap();
347347- assert_eq!(parsed.text, "Hello!");
348348- }
349349-350333 /// Helper macro for testing enum variant deserialisation.
351334 macro_rules! assert_deserialize {
352335 ($type:ty, $($json:literal => $variant:expr),+ $(,)?) => {
···491474 "text": "Hello!"
492475 }
493476 }
494494- });
477477+ })
478478+ .to_string();
495479496496- let raw: RawEvent = serde_json::from_value(json).unwrap();
497497- assert_eq!(raw.id, 12345);
498498- assert_eq!(raw.type_, "record");
480480+ let raw: RawEvent = serde_json::from_str(&json).unwrap();
481481+ assert_eq!(raw.owned.id, 12345);
482482+ assert_eq!(raw.owned.type_, "record");
499483500500- let event = raw.into_event().unwrap();
484484+ let event = raw
485485+ .owned
486486+ .into_event(raw.record.map(|r| r.owned), None)
487487+ .unwrap();
501488 match event {
502489 Event::Record(r) => {
503490 assert_eq!(r.id, 12345);
···505492 assert_eq!(r.did, "did:plc:abc123");
506493 assert_eq!(r.collection, "app.bsky.feed.post");
507494 assert_eq!(r.action, RecordAction::Create);
508508- assert!(r.record.is_some());
509509- assert_eq!(r.record.unwrap().record_type(), Some("app.bsky.feed.post"));
510495 }
511496 _ => panic!("Expected Record event"),
512497 }
···523508 "is_active": true,
524509 "status": "active"
525510 }
526526- });
511511+ })
512512+ .to_string();
527513528528- let raw: RawEvent = serde_json::from_value(json).unwrap();
529529- let event = raw.into_event().unwrap();
514514+ let raw: RawEvent = serde_json::from_str(&json).unwrap();
515515+ let event = raw.owned.into_event(None, None).unwrap();
530516531517 match event {
532518 Event::Identity(i) => {
···555541 "cid": null,
556542 "record": null
557543 }
558558- });
544544+ })
545545+ .to_string();
559546560560- let raw: RawEvent = serde_json::from_value(json).unwrap();
561561- let event = raw.into_event().unwrap();
547547+ let raw: RawEvent = serde_json::from_str(&json).unwrap();
548548+ let event = raw
549549+ .owned
550550+ .into_event(raw.record.map(|r| r.owned), None)
551551+ .unwrap();
562552563553 match event {
564554 Event::Record(r) => {