atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.authors
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// A single author in a Weaver notebook.
9#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct AuthorListItem<'a> {
21 #[serde(skip_serializing_if = "std::option::Option::is_none")]
22 pub index: std::option::Option<i64>,
23 #[serde(skip_serializing_if = "std::option::Option::is_none")]
24 #[serde(borrow)]
25 pub profile: std::option::Option<AuthorListItemProfile<'a>>,
26}
27
28pub mod author_list_item_state {
29
30 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
31 #[allow(unused)]
32 use ::core::marker::PhantomData;
33 mod sealed {
34 pub trait Sealed {}
35 }
36 /// State trait tracking which required fields have been set
37 pub trait State: sealed::Sealed {
38 type ProfileIndex;
39 }
40 /// Empty state - all required fields are unset
41 pub struct Empty(());
42 impl sealed::Sealed for Empty {}
43 impl State for Empty {
44 type ProfileIndex = Unset;
45 }
46 ///State transition - sets the `profile_index` field to Set
47 pub struct SetProfileIndex<S: State = Empty>(PhantomData<fn() -> S>);
48 impl<S: State> sealed::Sealed for SetProfileIndex<S> {}
49 impl<S: State> State for SetProfileIndex<S> {
50 type ProfileIndex = Set<members::profile_index>;
51 }
52 /// Marker types for field names
53 #[allow(non_camel_case_types)]
54 pub mod members {
55 ///Marker type for the `profile_index` field
56 pub struct profile_index(());
57 }
58}
59
60/// Builder for constructing an instance of this type
61pub struct AuthorListItemBuilder<'a, S: author_list_item_state::State> {
62 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
63 __unsafe_private_named: (
64 ::core::option::Option<i64>,
65 ::core::option::Option<AuthorListItemProfile<'a>>,
66 ),
67 _phantom: ::core::marker::PhantomData<&'a ()>,
68}
69
70impl<'a> AuthorListItem<'a> {
71 /// Create a new builder for this type
72 pub fn new() -> AuthorListItemBuilder<'a, author_list_item_state::Empty> {
73 AuthorListItemBuilder::new()
74 }
75}
76
77impl<'a> AuthorListItemBuilder<'a, author_list_item_state::Empty> {
78 /// Create a new builder with all fields unset
79 pub fn new() -> Self {
80 AuthorListItemBuilder {
81 _phantom_state: ::core::marker::PhantomData,
82 __unsafe_private_named: (None, None),
83 _phantom: ::core::marker::PhantomData,
84 }
85 }
86}
87
88impl<'a, S: author_list_item_state::State> AuthorListItemBuilder<'a, S> {
89 /// Set the `index` field (optional)
90 pub fn index(mut self, value: impl Into<Option<i64>>) -> Self {
91 self.__unsafe_private_named.0 = value.into();
92 self
93 }
94 /// Set the `index` field to an Option value (optional)
95 pub fn maybe_index(mut self, value: Option<i64>) -> Self {
96 self.__unsafe_private_named.0 = value;
97 self
98 }
99}
100
101impl<'a, S: author_list_item_state::State> AuthorListItemBuilder<'a, S> {
102 /// Set the `profile` field (optional)
103 pub fn profile(
104 mut self,
105 value: impl Into<Option<AuthorListItemProfile<'a>>>,
106 ) -> Self {
107 self.__unsafe_private_named.1 = value.into();
108 self
109 }
110 /// Set the `profile` field to an Option value (optional)
111 pub fn maybe_profile(mut self, value: Option<AuthorListItemProfile<'a>>) -> Self {
112 self.__unsafe_private_named.1 = value;
113 self
114 }
115}
116
117impl<'a, S> AuthorListItemBuilder<'a, S>
118where
119 S: author_list_item_state::State,
120 S::ProfileIndex: author_list_item_state::IsSet,
121{
122 /// Build the final struct
123 pub fn build(self) -> AuthorListItem<'a> {
124 AuthorListItem {
125 index: self.__unsafe_private_named.0,
126 profile: self.__unsafe_private_named.1,
127 extra_data: Default::default(),
128 }
129 }
130 /// Build the final struct with custom extra_data
131 pub fn build_with_data(
132 self,
133 extra_data: std::collections::BTreeMap<
134 jacquard_common::smol_str::SmolStr,
135 jacquard_common::types::value::Data<'a>,
136 >,
137 ) -> AuthorListItem<'a> {
138 AuthorListItem {
139 index: self.__unsafe_private_named.0,
140 profile: self.__unsafe_private_named.1,
141 extra_data: Some(extra_data),
142 }
143 }
144}
145
146#[jacquard_derive::open_union]
147#[derive(
148 serde::Serialize,
149 serde::Deserialize,
150 Debug,
151 Clone,
152 PartialEq,
153 Eq,
154 jacquard_derive::IntoStatic
155)]
156#[serde(tag = "$type")]
157#[serde(bound(deserialize = "'de: 'a"))]
158pub enum AuthorListItemProfile<'a> {
159 #[serde(rename = "app.bsky.actor.defs#profileViewBasic")]
160 ProfileViewBasic(Box<crate::app_bsky::actor::ProfileViewBasic<'a>>),
161 #[serde(rename = "sh.weaver.actor.defs#profileView")]
162 ProfileView(Box<crate::sh_weaver::actor::ProfileView<'a>>),
163}
164
165fn lexicon_doc_sh_weaver_notebook_authors() -> ::jacquard_lexicon::lexicon::LexiconDoc<
166 'static,
167> {
168 ::jacquard_lexicon::lexicon::LexiconDoc {
169 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
170 id: ::jacquard_common::CowStr::new_static("sh.weaver.notebook.authors"),
171 revision: None,
172 description: None,
173 defs: {
174 let mut map = ::alloc::collections::BTreeMap::new();
175 map.insert(
176 ::jacquard_common::smol_str::SmolStr::new_static("authorListItem"),
177 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
178 description: Some(
179 ::jacquard_common::CowStr::new_static(
180 "A single author in a Weaver notebook.",
181 ),
182 ),
183 required: Some(
184 vec![
185 ::jacquard_common::smol_str::SmolStr::new_static("profile, index")
186 ],
187 ),
188 nullable: None,
189 properties: {
190 #[allow(unused_mut)]
191 let mut map = ::alloc::collections::BTreeMap::new();
192 map.insert(
193 ::jacquard_common::smol_str::SmolStr::new_static("index"),
194 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
195 description: None,
196 default: None,
197 minimum: None,
198 maximum: None,
199 r#enum: None,
200 r#const: None,
201 }),
202 );
203 map.insert(
204 ::jacquard_common::smol_str::SmolStr::new_static("profile"),
205 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
206 description: None,
207 refs: vec![
208 ::jacquard_common::CowStr::new_static("app.bsky.actor.defs#profileViewBasic"),
209 ::jacquard_common::CowStr::new_static("sh.weaver.actor.defs#profileView")
210 ],
211 closed: None,
212 }),
213 );
214 map
215 },
216 }),
217 );
218 map.insert(
219 ::jacquard_common::smol_str::SmolStr::new_static("main"),
220 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
221 description: Some(
222 ::jacquard_common::CowStr::new_static(
223 "Authors of a Weaver notebook.",
224 ),
225 ),
226 key: Some(::jacquard_common::CowStr::new_static("tid")),
227 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
228 description: None,
229 required: Some(
230 vec![
231 ::jacquard_common::smol_str::SmolStr::new_static("authorList")
232 ],
233 ),
234 nullable: None,
235 properties: {
236 #[allow(unused_mut)]
237 let mut map = ::alloc::collections::BTreeMap::new();
238 map.insert(
239 ::jacquard_common::smol_str::SmolStr::new_static(
240 "authorList",
241 ),
242 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
243 description: None,
244 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
245 description: None,
246 r#ref: ::jacquard_common::CowStr::new_static(
247 "#authorListItem",
248 ),
249 }),
250 min_length: None,
251 max_length: None,
252 }),
253 );
254 map.insert(
255 ::jacquard_common::smol_str::SmolStr::new_static(
256 "createdAt",
257 ),
258 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
259 description: None,
260 format: Some(
261 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
262 ),
263 default: None,
264 min_length: None,
265 max_length: None,
266 min_graphemes: None,
267 max_graphemes: None,
268 r#enum: None,
269 r#const: None,
270 known_values: None,
271 }),
272 );
273 map
274 },
275 }),
276 }),
277 );
278 map
279 },
280 }
281}
282
283impl<'a> ::jacquard_lexicon::schema::LexiconSchema for AuthorListItem<'a> {
284 fn nsid() -> &'static str {
285 "sh.weaver.notebook.authors"
286 }
287 fn def_name() -> &'static str {
288 "authorListItem"
289 }
290 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
291 lexicon_doc_sh_weaver_notebook_authors()
292 }
293 fn validate(
294 &self,
295 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
296 Ok(())
297 }
298}
299
300/// Authors of a Weaver notebook.
301#[jacquard_derive::lexicon]
302#[derive(
303 serde::Serialize,
304 serde::Deserialize,
305 Debug,
306 Clone,
307 PartialEq,
308 Eq,
309 jacquard_derive::IntoStatic
310)]
311#[serde(rename_all = "camelCase")]
312pub struct Authors<'a> {
313 #[serde(borrow)]
314 pub author_list: Vec<crate::sh_weaver::notebook::authors::AuthorListItem<'a>>,
315 #[serde(skip_serializing_if = "std::option::Option::is_none")]
316 pub created_at: std::option::Option<jacquard_common::types::string::Datetime>,
317}
318
319pub mod authors_state {
320
321 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
322 #[allow(unused)]
323 use ::core::marker::PhantomData;
324 mod sealed {
325 pub trait Sealed {}
326 }
327 /// State trait tracking which required fields have been set
328 pub trait State: sealed::Sealed {
329 type AuthorList;
330 }
331 /// Empty state - all required fields are unset
332 pub struct Empty(());
333 impl sealed::Sealed for Empty {}
334 impl State for Empty {
335 type AuthorList = Unset;
336 }
337 ///State transition - sets the `author_list` field to Set
338 pub struct SetAuthorList<S: State = Empty>(PhantomData<fn() -> S>);
339 impl<S: State> sealed::Sealed for SetAuthorList<S> {}
340 impl<S: State> State for SetAuthorList<S> {
341 type AuthorList = Set<members::author_list>;
342 }
343 /// Marker types for field names
344 #[allow(non_camel_case_types)]
345 pub mod members {
346 ///Marker type for the `author_list` field
347 pub struct author_list(());
348 }
349}
350
351/// Builder for constructing an instance of this type
352pub struct AuthorsBuilder<'a, S: authors_state::State> {
353 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
354 __unsafe_private_named: (
355 ::core::option::Option<
356 Vec<crate::sh_weaver::notebook::authors::AuthorListItem<'a>>,
357 >,
358 ::core::option::Option<jacquard_common::types::string::Datetime>,
359 ),
360 _phantom: ::core::marker::PhantomData<&'a ()>,
361}
362
363impl<'a> Authors<'a> {
364 /// Create a new builder for this type
365 pub fn new() -> AuthorsBuilder<'a, authors_state::Empty> {
366 AuthorsBuilder::new()
367 }
368}
369
370impl<'a> AuthorsBuilder<'a, authors_state::Empty> {
371 /// Create a new builder with all fields unset
372 pub fn new() -> Self {
373 AuthorsBuilder {
374 _phantom_state: ::core::marker::PhantomData,
375 __unsafe_private_named: (None, None),
376 _phantom: ::core::marker::PhantomData,
377 }
378 }
379}
380
381impl<'a, S> AuthorsBuilder<'a, S>
382where
383 S: authors_state::State,
384 S::AuthorList: authors_state::IsUnset,
385{
386 /// Set the `authorList` field (required)
387 pub fn author_list(
388 mut self,
389 value: impl Into<Vec<crate::sh_weaver::notebook::authors::AuthorListItem<'a>>>,
390 ) -> AuthorsBuilder<'a, authors_state::SetAuthorList<S>> {
391 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
392 AuthorsBuilder {
393 _phantom_state: ::core::marker::PhantomData,
394 __unsafe_private_named: self.__unsafe_private_named,
395 _phantom: ::core::marker::PhantomData,
396 }
397 }
398}
399
400impl<'a, S: authors_state::State> AuthorsBuilder<'a, S> {
401 /// Set the `createdAt` field (optional)
402 pub fn created_at(
403 mut self,
404 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
405 ) -> Self {
406 self.__unsafe_private_named.1 = value.into();
407 self
408 }
409 /// Set the `createdAt` field to an Option value (optional)
410 pub fn maybe_created_at(
411 mut self,
412 value: Option<jacquard_common::types::string::Datetime>,
413 ) -> Self {
414 self.__unsafe_private_named.1 = value;
415 self
416 }
417}
418
419impl<'a, S> AuthorsBuilder<'a, S>
420where
421 S: authors_state::State,
422 S::AuthorList: authors_state::IsSet,
423{
424 /// Build the final struct
425 pub fn build(self) -> Authors<'a> {
426 Authors {
427 author_list: self.__unsafe_private_named.0.unwrap(),
428 created_at: self.__unsafe_private_named.1,
429 extra_data: Default::default(),
430 }
431 }
432 /// Build the final struct with custom extra_data
433 pub fn build_with_data(
434 self,
435 extra_data: std::collections::BTreeMap<
436 jacquard_common::smol_str::SmolStr,
437 jacquard_common::types::value::Data<'a>,
438 >,
439 ) -> Authors<'a> {
440 Authors {
441 author_list: self.__unsafe_private_named.0.unwrap(),
442 created_at: self.__unsafe_private_named.1,
443 extra_data: Some(extra_data),
444 }
445 }
446}
447
448impl<'a> Authors<'a> {
449 pub fn uri(
450 uri: impl Into<jacquard_common::CowStr<'a>>,
451 ) -> Result<
452 jacquard_common::types::uri::RecordUri<'a, AuthorsRecord>,
453 jacquard_common::types::uri::UriError,
454 > {
455 jacquard_common::types::uri::RecordUri::try_from_uri(
456 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
457 )
458 }
459}
460
461/// Typed wrapper for GetRecord response with this collection's record type.
462#[derive(
463 serde::Serialize,
464 serde::Deserialize,
465 Debug,
466 Clone,
467 PartialEq,
468 Eq,
469 jacquard_derive::IntoStatic
470)]
471#[serde(rename_all = "camelCase")]
472pub struct AuthorsGetRecordOutput<'a> {
473 #[serde(skip_serializing_if = "std::option::Option::is_none")]
474 #[serde(borrow)]
475 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
476 #[serde(borrow)]
477 pub uri: jacquard_common::types::string::AtUri<'a>,
478 #[serde(borrow)]
479 pub value: Authors<'a>,
480}
481
482impl From<AuthorsGetRecordOutput<'_>> for Authors<'_> {
483 fn from(output: AuthorsGetRecordOutput<'_>) -> Self {
484 use jacquard_common::IntoStatic;
485 output.value.into_static()
486 }
487}
488
489impl jacquard_common::types::collection::Collection for Authors<'_> {
490 const NSID: &'static str = "sh.weaver.notebook.authors";
491 type Record = AuthorsRecord;
492}
493
494/// Marker type for deserializing records from this collection.
495#[derive(Debug, serde::Serialize, serde::Deserialize)]
496pub struct AuthorsRecord;
497impl jacquard_common::xrpc::XrpcResp for AuthorsRecord {
498 const NSID: &'static str = "sh.weaver.notebook.authors";
499 const ENCODING: &'static str = "application/json";
500 type Output<'de> = AuthorsGetRecordOutput<'de>;
501 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
502}
503
504impl jacquard_common::types::collection::Collection for AuthorsRecord {
505 const NSID: &'static str = "sh.weaver.notebook.authors";
506 type Record = AuthorsRecord;
507}
508
509impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Authors<'a> {
510 fn nsid() -> &'static str {
511 "sh.weaver.notebook.authors"
512 }
513 fn def_name() -> &'static str {
514 "main"
515 }
516 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
517 lexicon_doc_sh_weaver_notebook_authors()
518 }
519 fn validate(
520 &self,
521 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
522 Ok(())
523 }
524}