jacquard_api/pub_leaflet/blocks/
poll.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13
14#[allow(unused_imports)]
15use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
16use jacquard_derive::{IntoStatic, lexicon};
17use jacquard_lexicon::lexicon::LexiconDoc;
18use jacquard_lexicon::schema::LexiconSchema;
19
20#[allow(unused_imports)]
21use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
22use serde::{Serialize, Deserialize};
23use crate::com_atproto::repo::strong_ref::StrongRef;
24
25#[lexicon]
26#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
27#[serde(rename_all = "camelCase")]
28pub struct Poll<'a> {
29 #[serde(borrow)]
30 pub poll_ref: StrongRef<'a>,
31}
32
33impl<'a> LexiconSchema for Poll<'a> {
34 fn nsid() -> &'static str {
35 "pub.leaflet.blocks.poll"
36 }
37 fn def_name() -> &'static str {
38 "main"
39 }
40 fn lexicon_doc() -> LexiconDoc<'static> {
41 lexicon_doc_pub_leaflet_blocks_poll()
42 }
43 fn validate(&self) -> Result<(), ConstraintError> {
44 Ok(())
45 }
46}
47
48pub mod poll_state {
49
50 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
51 #[allow(unused)]
52 use ::core::marker::PhantomData;
53 mod sealed {
54 pub trait Sealed {}
55 }
56 pub trait State: sealed::Sealed {
58 type PollRef;
59 }
60 pub struct Empty(());
62 impl sealed::Sealed for Empty {}
63 impl State for Empty {
64 type PollRef = Unset;
65 }
66 pub struct SetPollRef<S: State = Empty>(PhantomData<fn() -> S>);
68 impl<S: State> sealed::Sealed for SetPollRef<S> {}
69 impl<S: State> State for SetPollRef<S> {
70 type PollRef = Set<members::poll_ref>;
71 }
72 #[allow(non_camel_case_types)]
74 pub mod members {
75 pub struct poll_ref(());
77 }
78}
79
80pub struct PollBuilder<'a, S: poll_state::State> {
82 _state: PhantomData<fn() -> S>,
83 _fields: (Option<StrongRef<'a>>,),
84 _lifetime: PhantomData<&'a ()>,
85}
86
87impl<'a> Poll<'a> {
88 pub fn new() -> PollBuilder<'a, poll_state::Empty> {
90 PollBuilder::new()
91 }
92}
93
94impl<'a> PollBuilder<'a, poll_state::Empty> {
95 pub fn new() -> Self {
97 PollBuilder {
98 _state: PhantomData,
99 _fields: (None,),
100 _lifetime: PhantomData,
101 }
102 }
103}
104
105impl<'a, S> PollBuilder<'a, S>
106where
107 S: poll_state::State,
108 S::PollRef: poll_state::IsUnset,
109{
110 pub fn poll_ref(
112 mut self,
113 value: impl Into<StrongRef<'a>>,
114 ) -> PollBuilder<'a, poll_state::SetPollRef<S>> {
115 self._fields.0 = Option::Some(value.into());
116 PollBuilder {
117 _state: PhantomData,
118 _fields: self._fields,
119 _lifetime: PhantomData,
120 }
121 }
122}
123
124impl<'a, S> PollBuilder<'a, S>
125where
126 S: poll_state::State,
127 S::PollRef: poll_state::IsSet,
128{
129 pub fn build(self) -> Poll<'a> {
131 Poll {
132 poll_ref: self._fields.0.unwrap(),
133 extra_data: Default::default(),
134 }
135 }
136 pub fn build_with_data(
138 self,
139 extra_data: BTreeMap<
140 jacquard_common::deps::smol_str::SmolStr,
141 jacquard_common::types::value::Data<'a>,
142 >,
143 ) -> Poll<'a> {
144 Poll {
145 poll_ref: self._fields.0.unwrap(),
146 extra_data: Some(extra_data),
147 }
148 }
149}
150
151fn lexicon_doc_pub_leaflet_blocks_poll() -> LexiconDoc<'static> {
152 #[allow(unused_imports)]
153 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
154 use jacquard_lexicon::lexicon::*;
155 use alloc::collections::BTreeMap;
156 LexiconDoc {
157 lexicon: Lexicon::Lexicon1,
158 id: CowStr::new_static("pub.leaflet.blocks.poll"),
159 defs: {
160 let mut map = BTreeMap::new();
161 map.insert(
162 SmolStr::new_static("main"),
163 LexUserType::Object(LexObject {
164 required: Some(vec![SmolStr::new_static("pollRef")]),
165 properties: {
166 #[allow(unused_mut)]
167 let mut map = BTreeMap::new();
168 map.insert(
169 SmolStr::new_static("pollRef"),
170 LexObjectProperty::Ref(LexRef {
171 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
172 ..Default::default()
173 }),
174 );
175 map
176 },
177 ..Default::default()
178 }),
179 );
180 map
181 },
182 ..Default::default()
183 }
184}