Something went wrong. Try again.
atproto made easy crates.io/crates/jacquard
atproto rust
Something went wrong. Try again.
44 kB · 1277 lines
Rust
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277// @generated by jacquard-lexicon. DO NOT EDIT.//// Lexicon: network.slices.tools.document//// This file was automatically generated from Lexicon schemas.// Any manual changes will be overwritten on the next regeneration.
#[allow(unused_imports)]use alloc::collections::BTreeMap;
#[allow(unused_imports)]use core::marker::PhantomData;use jacquard_common::CowStr;
#[allow(unused_imports)]use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;use jacquard_common::types::blob::BlobRef;use jacquard_common::types::collection::{Collection, RecordError};use jacquard_common::types::string::{AtUri, Cid, Datetime};use jacquard_common::types::uri::{RecordUri, UriError};use jacquard_common::xrpc::XrpcResp;use jacquard_derive::{IntoStatic, lexicon, open_union};use jacquard_lexicon::lexicon::LexiconDoc;use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]use jacquard_lexicon::validation::{ConstraintError, ValidationPath};use serde::{Serialize, Deserialize};use crate::network_slices::tools::richtext::facet::Facet;use crate::network_slices::tools::document;/// A fenced code block
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]#[serde(rename_all = "camelCase")]pub struct CodeBlock<'a> { #[serde(borrow)] pub code: CowStr<'a>, #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub lang: Option<CowStr<'a>>,}
/// A heading block (h1-h3) with optional inline formatting
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct Heading<'a> { #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub facets: Option<Vec<Facet<'a>>>, pub level: i64, #[serde(borrow)] pub text: CowStr<'a>,}
/// An embedded image with alt text
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct ImageEmbed<'a> { ///Alt text for accessibility #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub alt: Option<CowStr<'a>>, #[serde(borrow)] pub image: BlobRef<'a>,}
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct Document<'a> { ///Document content as array of blocks #[serde(borrow)] pub blocks: Vec<DocumentBlocksItem<'a>>, pub created_at: Datetime, ///URL-friendly identifier, unique per author #[serde(borrow)] pub slug: CowStr<'a>, ///Document title #[serde(borrow)] pub title: CowStr<'a>, #[serde(skip_serializing_if = "Option::is_none")] pub updated_at: Option<Datetime>,}
#[open_union]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(tag = "$type")]#[serde(bound(deserialize = "'de: 'a"))]pub enum DocumentBlocksItem<'a> { #[serde(rename = "network.slices.tools.document#paragraph")] Paragraph(Box<document::Paragraph<'a>>), #[serde(rename = "network.slices.tools.document#heading")] Heading(Box<document::Heading<'a>>), #[serde(rename = "network.slices.tools.document#codeBlock")] CodeBlock(Box<document::CodeBlock<'a>>), #[serde(rename = "network.slices.tools.document#quote")] Quote(Box<document::Quote<'a>>), #[serde(rename = "network.slices.tools.document#tangledEmbed")] TangledEmbed(Box<document::TangledEmbed<'a>>), #[serde(rename = "network.slices.tools.document#imageEmbed")] ImageEmbed(Box<document::ImageEmbed<'a>>),}
/// Typed wrapper for GetRecord response with this collection's record type.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct DocumentGetRecordOutput<'a> { #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub cid: Option<Cid<'a>>, #[serde(borrow)] pub uri: AtUri<'a>, #[serde(borrow)] pub value: Document<'a>,}
/// A paragraph block with optional inline formatting
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]#[serde(rename_all = "camelCase")]pub struct Paragraph<'a> { #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub facets: Option<Vec<Facet<'a>>>, #[serde(borrow)] pub text: CowStr<'a>,}
/// A blockquote with optional inline formatting
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]#[serde(rename_all = "camelCase")]pub struct Quote<'a> { #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub facets: Option<Vec<Facet<'a>>>, #[serde(borrow)] pub text: CowStr<'a>,}
/// An embedded Tangled repo card
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]#[serde(rename_all = "camelCase")]pub struct TangledEmbed<'a> { ///The repo owner's handle #[serde(borrow)] pub handle: CowStr<'a>, ///The repository name #[serde(borrow)] pub repo: CowStr<'a>,}
impl<'a> Document<'a> { pub fn uri( uri: impl Into<CowStr<'a>>, ) -> Result<RecordUri<'a, DocumentRecord>, UriError> { RecordUri::try_from_uri(AtUri::new_cow(uri.into())?) }}
impl<'a> LexiconSchema for CodeBlock<'a> { fn nsid() -> &'static str { "network.slices.tools.document" } fn def_name() -> &'static str { "codeBlock" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_tools_document() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.code; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 20000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("code"), max: 20000usize, actual: <str>::len(value.as_ref()), }); } } if let Some(ref value) = self.lang { #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 50usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("lang"), max: 50usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
impl<'a> LexiconSchema for Heading<'a> { fn nsid() -> &'static str { "network.slices.tools.document" } fn def_name() -> &'static str { "heading" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_tools_document() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.level; if *value > 3i64 { return Err(ConstraintError::Maximum { path: ValidationPath::from_field("level"), max: 3i64, actual: *value, }); } } { let value = &self.level; if *value < 1i64 { return Err(ConstraintError::Minimum { path: ValidationPath::from_field("level"), min: 1i64, actual: *value, }); } } { let value = &self.text; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 300usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 300usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
impl<'a> LexiconSchema for ImageEmbed<'a> { fn nsid() -> &'static str { "network.slices.tools.document" } fn def_name() -> &'static str { "imageEmbed" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_tools_document() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.alt { #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 1000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("alt"), max: 1000usize, actual: <str>::len(value.as_ref()), }); } } { let value = &self.image; { let size = value.blob().size; if size > 1000000usize { return Err(ConstraintError::BlobTooLarge { path: ValidationPath::from_field("image"), max: 1000000usize, actual: size, }); } } } { let value = &self.image; { let mime = value.blob().mime_type.as_str(); let accepted: &[&str] = &["image/*"]; let matched = accepted .iter() .any(|pattern| { if *pattern == "*/*" { true } else if pattern.ends_with("/*") { let prefix = &pattern[..pattern.len() - 2]; mime.starts_with(prefix) && mime.as_bytes().get(prefix.len()) == Some(&b'/') } else { mime == *pattern } }); if !matched { return Err(ConstraintError::BlobMimeTypeNotAccepted { path: ValidationPath::from_field("image"), accepted: vec!["image/*".to_string()], actual: mime.to_string(), }); } } } Ok(()) }}
/// Marker type for deserializing records from this collection.
#[derive(Debug, Serialize, Deserialize)]pub struct DocumentRecord;impl XrpcResp for DocumentRecord { const NSID: &'static str = "network.slices.tools.document"; const ENCODING: &'static str = "application/json"; type Output<'de> = DocumentGetRecordOutput<'de>; type Err<'de> = RecordError<'de>;}
impl From<DocumentGetRecordOutput<'_>> for Document<'_> { fn from(output: DocumentGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() }}
impl Collection for Document<'_> { const NSID: &'static str = "network.slices.tools.document"; type Record = DocumentRecord;}
impl Collection for DocumentRecord { const NSID: &'static str = "network.slices.tools.document"; type Record = DocumentRecord;}
impl<'a> LexiconSchema for Document<'a> { fn nsid() -> &'static str { "network.slices.tools.document" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_tools_document() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.slug; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 100usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("slug"), max: 100usize, actual: <str>::len(value.as_ref()), }); } } { let value = &self.title; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 300usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("title"), max: 300usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
impl<'a> LexiconSchema for Paragraph<'a> { fn nsid() -> &'static str { "network.slices.tools.document" } fn def_name() -> &'static str { "paragraph" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_tools_document() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.text; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 10000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 10000usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
impl<'a> LexiconSchema for Quote<'a> { fn nsid() -> &'static str { "network.slices.tools.document" } fn def_name() -> &'static str { "quote" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_tools_document() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.text; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 5000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 5000usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
impl<'a> LexiconSchema for TangledEmbed<'a> { fn nsid() -> &'static str { "network.slices.tools.document" } fn def_name() -> &'static str { "tangledEmbed" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_tools_document() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.handle; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 300usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("handle"), max: 300usize, actual: <str>::len(value.as_ref()), }); } } { let value = &self.repo; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 300usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("repo"), max: 300usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
fn lexicon_doc_network_slices_tools_document() -> LexiconDoc<'static> { #[allow(unused_imports)] use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; use jacquard_lexicon::lexicon::*; use alloc::collections::BTreeMap; LexiconDoc { lexicon: Lexicon::Lexicon1, id: CowStr::new_static("network.slices.tools.document"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("codeBlock"), LexUserType::Object(LexObject { description: Some(CowStr::new_static("A fenced code block")), required: Some(vec![SmolStr::new_static("code")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("code"), LexObjectProperty::String(LexString { max_length: Some(20000usize), ..Default::default() }), ); map.insert( SmolStr::new_static("lang"), LexObjectProperty::String(LexString { max_length: Some(50usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("heading"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A heading block (h1-h3) with optional inline formatting", ), ), required: Some( vec![SmolStr::new_static("level"), SmolStr::new_static("text")], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("facets"), LexObjectProperty::Array(LexArray { items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static( "network.slices.tools.richtext.facet", ), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("level"), LexObjectProperty::Integer(LexInteger { minimum: Some(1i64), maximum: Some(3i64), ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { max_length: Some(300usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("imageEmbed"), LexUserType::Object(LexObject { description: Some( CowStr::new_static("An embedded image with alt text"), ), required: Some(vec![SmolStr::new_static("image")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("alt"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("Alt text for accessibility"), ), max_length: Some(1000usize), ..Default::default() }), ); map.insert( SmolStr::new_static("image"), LexObjectProperty::Blob(LexBlob { ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("main"), LexUserType::Record(LexRecord { key: Some(CowStr::new_static("tid")), record: LexRecordRecord::Object(LexObject { required: Some( vec![ SmolStr::new_static("title"), SmolStr::new_static("slug"), SmolStr::new_static("blocks"), SmolStr::new_static("createdAt") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("blocks"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static("Document content as array of blocks"), ), items: LexArrayItem::Union(LexRefUnion { refs: vec![ CowStr::new_static("#paragraph"), CowStr::new_static("#heading"), CowStr::new_static("#codeBlock"), CowStr::new_static("#quote"), CowStr::new_static("#tangledEmbed"), CowStr::new_static("#imageEmbed") ], ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("createdAt"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("slug"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "URL-friendly identifier, unique per author", ), ), max_length: Some(100usize), ..Default::default() }), ); map.insert( SmolStr::new_static("title"), LexObjectProperty::String(LexString { description: Some(CowStr::new_static("Document title")), max_length: Some(300usize), ..Default::default() }), ); map.insert( SmolStr::new_static("updatedAt"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map }, ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("paragraph"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A paragraph block with optional inline formatting", ), ), required: Some(vec![SmolStr::new_static("text")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("facets"), LexObjectProperty::Array(LexArray { items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static( "network.slices.tools.richtext.facet", ), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { max_length: Some(10000usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("quote"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A blockquote with optional inline formatting", ), ), required: Some(vec![SmolStr::new_static("text")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("facets"), LexObjectProperty::Array(LexArray { items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static( "network.slices.tools.richtext.facet", ), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { max_length: Some(5000usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("tangledEmbed"), LexUserType::Object(LexObject { description: Some( CowStr::new_static("An embedded Tangled repo card"), ), required: Some( vec![SmolStr::new_static("handle"), SmolStr::new_static("repo")], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("handle"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("The repo owner's handle"), ), max_length: Some(300usize), ..Default::default() }), ); map.insert( SmolStr::new_static("repo"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("The repository name"), ), max_length: Some(300usize), ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() }}
pub mod heading_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 Text; type Level; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Text = Unset; type Level = Unset; } ///State transition - sets the `text` field to Set pub struct SetText<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetText<S> {} impl<S: State> State for SetText<S> { type Text = Set<members::text>; type Level = S::Level; } ///State transition - sets the `level` field to Set pub struct SetLevel<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetLevel<S> {} impl<S: State> State for SetLevel<S> { type Text = S::Text; type Level = Set<members::level>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `text` field pub struct text(()); ///Marker type for the `level` field pub struct level(()); }}
/// Builder for constructing an instance of this typepub struct HeadingBuilder<'a, S: heading_state::State> { _state: PhantomData<fn() -> S>, _fields: (Option<Vec<Facet<'a>>>, Option<i64>, Option<CowStr<'a>>), _lifetime: PhantomData<&'a ()>,}
impl<'a> Heading<'a> { /// Create a new builder for this type pub fn new() -> HeadingBuilder<'a, heading_state::Empty> { HeadingBuilder::new() }}
impl<'a> HeadingBuilder<'a, heading_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { HeadingBuilder { _state: PhantomData, _fields: (None, None, None), _lifetime: PhantomData, } }}
impl<'a, S: heading_state::State> HeadingBuilder<'a, S> { /// Set the `facets` field (optional) pub fn facets(mut self, value: impl Into<Option<Vec<Facet<'a>>>>) -> Self { self._fields.0 = value.into(); self } /// Set the `facets` field to an Option value (optional) pub fn maybe_facets(mut self, value: Option<Vec<Facet<'a>>>) -> Self { self._fields.0 = value; self }}
impl<'a, S> HeadingBuilder<'a, S>where S: heading_state::State, S::Level: heading_state::IsUnset,{ /// Set the `level` field (required) pub fn level( mut self, value: impl Into<i64>, ) -> HeadingBuilder<'a, heading_state::SetLevel<S>> { self._fields.1 = Option::Some(value.into()); HeadingBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> HeadingBuilder<'a, S>where S: heading_state::State, S::Text: heading_state::IsUnset,{ /// Set the `text` field (required) pub fn text( mut self, value: impl Into<CowStr<'a>>, ) -> HeadingBuilder<'a, heading_state::SetText<S>> { self._fields.2 = Option::Some(value.into()); HeadingBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> HeadingBuilder<'a, S>where S: heading_state::State, S::Text: heading_state::IsSet, S::Level: heading_state::IsSet,{ /// Build the final struct pub fn build(self) -> Heading<'a> { Heading { facets: self._fields.0, level: self._fields.1.unwrap(), text: self._fields.2.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Heading<'a> { Heading { facets: self._fields.0, level: self._fields.1.unwrap(), text: self._fields.2.unwrap(), extra_data: Some(extra_data), } }}
pub mod image_embed_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 Image; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Image = Unset; } ///State transition - sets the `image` field to Set pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetImage<S> {} impl<S: State> State for SetImage<S> { type Image = Set<members::image>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `image` field pub struct image(()); }}
/// Builder for constructing an instance of this typepub struct ImageEmbedBuilder<'a, S: image_embed_state::State> { _state: PhantomData<fn() -> S>, _fields: (Option<CowStr<'a>>, Option<BlobRef<'a>>), _lifetime: PhantomData<&'a ()>,}
impl<'a> ImageEmbed<'a> { /// Create a new builder for this type pub fn new() -> ImageEmbedBuilder<'a, image_embed_state::Empty> { ImageEmbedBuilder::new() }}
impl<'a> ImageEmbedBuilder<'a, image_embed_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { ImageEmbedBuilder { _state: PhantomData, _fields: (None, None), _lifetime: PhantomData, } }}
impl<'a, S: image_embed_state::State> ImageEmbedBuilder<'a, S> { /// Set the `alt` field (optional) pub fn alt(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self { self._fields.0 = value.into(); self } /// Set the `alt` field to an Option value (optional) pub fn maybe_alt(mut self, value: Option<CowStr<'a>>) -> Self { self._fields.0 = value; self }}
impl<'a, S> ImageEmbedBuilder<'a, S>where S: image_embed_state::State, S::Image: image_embed_state::IsUnset,{ /// Set the `image` field (required) pub fn image( mut self, value: impl Into<BlobRef<'a>>, ) -> ImageEmbedBuilder<'a, image_embed_state::SetImage<S>> { self._fields.1 = Option::Some(value.into()); ImageEmbedBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> ImageEmbedBuilder<'a, S>where S: image_embed_state::State, S::Image: image_embed_state::IsSet,{ /// Build the final struct pub fn build(self) -> ImageEmbed<'a> { ImageEmbed { alt: self._fields.0, image: self._fields.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> ImageEmbed<'a> { ImageEmbed { alt: self._fields.0, image: self._fields.1.unwrap(), extra_data: Some(extra_data), } }}
pub mod document_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 Slug; type Blocks; type CreatedAt; type Title; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Slug = Unset; type Blocks = Unset; type CreatedAt = Unset; type Title = Unset; } ///State transition - sets the `slug` field to Set pub struct SetSlug<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetSlug<S> {} impl<S: State> State for SetSlug<S> { type Slug = Set<members::slug>; type Blocks = S::Blocks; type CreatedAt = S::CreatedAt; type Title = S::Title; } ///State transition - sets the `blocks` field to Set pub struct SetBlocks<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetBlocks<S> {} impl<S: State> State for SetBlocks<S> { type Slug = S::Slug; type Blocks = Set<members::blocks>; type CreatedAt = S::CreatedAt; type Title = S::Title; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetCreatedAt<S> {} impl<S: State> State for SetCreatedAt<S> { type Slug = S::Slug; type Blocks = S::Blocks; type CreatedAt = Set<members::created_at>; type Title = S::Title; } ///State transition - sets the `title` field to Set pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetTitle<S> {} impl<S: State> State for SetTitle<S> { type Slug = S::Slug; type Blocks = S::Blocks; type CreatedAt = S::CreatedAt; type Title = Set<members::title>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `slug` field pub struct slug(()); ///Marker type for the `blocks` field pub struct blocks(()); ///Marker type for the `created_at` field pub struct created_at(()); ///Marker type for the `title` field pub struct title(()); }}
/// Builder for constructing an instance of this typepub struct DocumentBuilder<'a, S: document_state::State> { _state: PhantomData<fn() -> S>, _fields: ( Option<Vec<DocumentBlocksItem<'a>>>, Option<Datetime>, Option<CowStr<'a>>, Option<CowStr<'a>>, Option<Datetime>, ), _lifetime: PhantomData<&'a ()>,}
impl<'a> Document<'a> { /// Create a new builder for this type pub fn new() -> DocumentBuilder<'a, document_state::Empty> { DocumentBuilder::new() }}
impl<'a> DocumentBuilder<'a, document_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { DocumentBuilder { _state: PhantomData, _fields: (None, None, None, None, None), _lifetime: PhantomData, } }}
impl<'a, S> DocumentBuilder<'a, S>where S: document_state::State, S::Blocks: document_state::IsUnset,{ /// Set the `blocks` field (required) pub fn blocks( mut self, value: impl Into<Vec<DocumentBlocksItem<'a>>>, ) -> DocumentBuilder<'a, document_state::SetBlocks<S>> { self._fields.0 = Option::Some(value.into()); DocumentBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> DocumentBuilder<'a, S>where S: document_state::State, S::CreatedAt: document_state::IsUnset,{ /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into<Datetime>, ) -> DocumentBuilder<'a, document_state::SetCreatedAt<S>> { self._fields.1 = Option::Some(value.into()); DocumentBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> DocumentBuilder<'a, S>where S: document_state::State, S::Slug: document_state::IsUnset,{ /// Set the `slug` field (required) pub fn slug( mut self, value: impl Into<CowStr<'a>>, ) -> DocumentBuilder<'a, document_state::SetSlug<S>> { self._fields.2 = Option::Some(value.into()); DocumentBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> DocumentBuilder<'a, S>where S: document_state::State, S::Title: document_state::IsUnset,{ /// Set the `title` field (required) pub fn title( mut self, value: impl Into<CowStr<'a>>, ) -> DocumentBuilder<'a, document_state::SetTitle<S>> { self._fields.3 = Option::Some(value.into()); DocumentBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> { /// Set the `updatedAt` field (optional) pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self { self._fields.4 = value.into(); self } /// Set the `updatedAt` field to an Option value (optional) pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self { self._fields.4 = value; self }}
impl<'a, S> DocumentBuilder<'a, S>where S: document_state::State, S::Slug: document_state::IsSet, S::Blocks: document_state::IsSet, S::CreatedAt: document_state::IsSet, S::Title: document_state::IsSet,{ /// Build the final struct pub fn build(self) -> Document<'a> { Document { blocks: self._fields.0.unwrap(), created_at: self._fields.1.unwrap(), slug: self._fields.2.unwrap(), title: self._fields.3.unwrap(), updated_at: self._fields.4, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Document<'a> { Document { blocks: self._fields.0.unwrap(), created_at: self._fields.1.unwrap(), slug: self._fields.2.unwrap(), title: self._fields.3.unwrap(), updated_at: self._fields.4, extra_data: Some(extra_data), } }}