atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.notification.listNotifications
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[derive(
9 serde::Serialize,
10 serde::Deserialize,
11 Debug,
12 Clone,
13 PartialEq,
14 Eq,
15 jacquard_derive::IntoStatic
16)]
17#[serde(rename_all = "camelCase")]
18pub struct ListNotifications<'a> {
19 #[serde(skip_serializing_if = "std::option::Option::is_none")]
20 #[serde(borrow)]
21 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
22 ///(default: 50, min: 1, max: 100)
23 #[serde(skip_serializing_if = "std::option::Option::is_none")]
24 pub limit: std::option::Option<i64>,
25 #[serde(skip_serializing_if = "std::option::Option::is_none")]
26 pub priority: std::option::Option<bool>,
27 #[serde(skip_serializing_if = "std::option::Option::is_none")]
28 #[serde(borrow)]
29 pub reasons: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
30 #[serde(skip_serializing_if = "std::option::Option::is_none")]
31 pub seen_at: std::option::Option<jacquard_common::types::string::Datetime>,
32}
33
34pub mod list_notifications_state {
35
36 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
37 #[allow(unused)]
38 use ::core::marker::PhantomData;
39 mod sealed {
40 pub trait Sealed {}
41 }
42 /// State trait tracking which required fields have been set
43 pub trait State: sealed::Sealed {}
44 /// Empty state - all required fields are unset
45 pub struct Empty(());
46 impl sealed::Sealed for Empty {}
47 impl State for Empty {}
48 /// Marker types for field names
49 #[allow(non_camel_case_types)]
50 pub mod members {}
51}
52
53/// Builder for constructing an instance of this type
54pub struct ListNotificationsBuilder<'a, S: list_notifications_state::State> {
55 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
56 __unsafe_private_named: (
57 ::core::option::Option<jacquard_common::CowStr<'a>>,
58 ::core::option::Option<i64>,
59 ::core::option::Option<bool>,
60 ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
61 ::core::option::Option<jacquard_common::types::string::Datetime>,
62 ),
63 _phantom: ::core::marker::PhantomData<&'a ()>,
64}
65
66impl<'a> ListNotifications<'a> {
67 /// Create a new builder for this type
68 pub fn new() -> ListNotificationsBuilder<'a, list_notifications_state::Empty> {
69 ListNotificationsBuilder::new()
70 }
71}
72
73impl<'a> ListNotificationsBuilder<'a, list_notifications_state::Empty> {
74 /// Create a new builder with all fields unset
75 pub fn new() -> Self {
76 ListNotificationsBuilder {
77 _phantom_state: ::core::marker::PhantomData,
78 __unsafe_private_named: (None, None, None, None, None),
79 _phantom: ::core::marker::PhantomData,
80 }
81 }
82}
83
84impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
85 /// Set the `cursor` field (optional)
86 pub fn cursor(
87 mut self,
88 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
89 ) -> Self {
90 self.__unsafe_private_named.0 = value.into();
91 self
92 }
93 /// Set the `cursor` field to an Option value (optional)
94 pub fn maybe_cursor(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
95 self.__unsafe_private_named.0 = value;
96 self
97 }
98}
99
100impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
101 /// Set the `limit` field (optional)
102 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
103 self.__unsafe_private_named.1 = value.into();
104 self
105 }
106 /// Set the `limit` field to an Option value (optional)
107 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
108 self.__unsafe_private_named.1 = value;
109 self
110 }
111}
112
113impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
114 /// Set the `priority` field (optional)
115 pub fn priority(mut self, value: impl Into<Option<bool>>) -> Self {
116 self.__unsafe_private_named.2 = value.into();
117 self
118 }
119 /// Set the `priority` field to an Option value (optional)
120 pub fn maybe_priority(mut self, value: Option<bool>) -> Self {
121 self.__unsafe_private_named.2 = value;
122 self
123 }
124}
125
126impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
127 /// Set the `reasons` field (optional)
128 pub fn reasons(
129 mut self,
130 value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>,
131 ) -> Self {
132 self.__unsafe_private_named.3 = value.into();
133 self
134 }
135 /// Set the `reasons` field to an Option value (optional)
136 pub fn maybe_reasons(
137 mut self,
138 value: Option<Vec<jacquard_common::CowStr<'a>>>,
139 ) -> Self {
140 self.__unsafe_private_named.3 = value;
141 self
142 }
143}
144
145impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
146 /// Set the `seenAt` field (optional)
147 pub fn seen_at(
148 mut self,
149 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
150 ) -> Self {
151 self.__unsafe_private_named.4 = value.into();
152 self
153 }
154 /// Set the `seenAt` field to an Option value (optional)
155 pub fn maybe_seen_at(
156 mut self,
157 value: Option<jacquard_common::types::string::Datetime>,
158 ) -> Self {
159 self.__unsafe_private_named.4 = value;
160 self
161 }
162}
163
164impl<'a, S> ListNotificationsBuilder<'a, S>
165where
166 S: list_notifications_state::State,
167{
168 /// Build the final struct
169 pub fn build(self) -> ListNotifications<'a> {
170 ListNotifications {
171 cursor: self.__unsafe_private_named.0,
172 limit: self.__unsafe_private_named.1,
173 priority: self.__unsafe_private_named.2,
174 reasons: self.__unsafe_private_named.3,
175 seen_at: self.__unsafe_private_named.4,
176 }
177 }
178}
179
180#[jacquard_derive::lexicon]
181#[derive(
182 serde::Serialize,
183 serde::Deserialize,
184 Debug,
185 Clone,
186 PartialEq,
187 Eq,
188 jacquard_derive::IntoStatic
189)]
190#[serde(rename_all = "camelCase")]
191pub struct ListNotificationsOutput<'a> {
192 #[serde(skip_serializing_if = "std::option::Option::is_none")]
193 #[serde(borrow)]
194 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
195 #[serde(borrow)]
196 pub notifications: Vec<
197 crate::app_bsky::notification::list_notifications::Notification<'a>,
198 >,
199 #[serde(skip_serializing_if = "std::option::Option::is_none")]
200 pub priority: std::option::Option<bool>,
201 #[serde(skip_serializing_if = "std::option::Option::is_none")]
202 pub seen_at: std::option::Option<jacquard_common::types::string::Datetime>,
203}
204
205/// Response type for
206///app.bsky.notification.listNotifications
207pub struct ListNotificationsResponse;
208impl jacquard_common::xrpc::XrpcResp for ListNotificationsResponse {
209 const NSID: &'static str = "app.bsky.notification.listNotifications";
210 const ENCODING: &'static str = "application/json";
211 type Output<'de> = ListNotificationsOutput<'de>;
212 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
213}
214
215impl<'a> jacquard_common::xrpc::XrpcRequest for ListNotifications<'a> {
216 const NSID: &'static str = "app.bsky.notification.listNotifications";
217 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
218 type Response = ListNotificationsResponse;
219}
220
221/// Endpoint type for
222///app.bsky.notification.listNotifications
223pub struct ListNotificationsRequest;
224impl jacquard_common::xrpc::XrpcEndpoint for ListNotificationsRequest {
225 const PATH: &'static str = "/xrpc/app.bsky.notification.listNotifications";
226 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
227 type Request<'de> = ListNotifications<'de>;
228 type Response = ListNotificationsResponse;
229}
230
231#[jacquard_derive::lexicon]
232#[derive(
233 serde::Serialize,
234 serde::Deserialize,
235 Debug,
236 Clone,
237 PartialEq,
238 Eq,
239 jacquard_derive::IntoStatic
240)]
241#[serde(rename_all = "camelCase")]
242pub struct Notification<'a> {
243 #[serde(borrow)]
244 pub author: crate::app_bsky::actor::ProfileView<'a>,
245 #[serde(borrow)]
246 pub cid: jacquard_common::types::string::Cid<'a>,
247 pub indexed_at: jacquard_common::types::string::Datetime,
248 pub is_read: bool,
249 #[serde(skip_serializing_if = "std::option::Option::is_none")]
250 #[serde(borrow)]
251 pub labels: std::option::Option<Vec<crate::com_atproto::label::Label<'a>>>,
252 /// The reason why this notification was delivered - e.g. your post was liked, or you received a new follower.
253 #[serde(borrow)]
254 pub reason: NotificationReason<'a>,
255 #[serde(skip_serializing_if = "std::option::Option::is_none")]
256 #[serde(borrow)]
257 pub reason_subject: std::option::Option<jacquard_common::types::string::AtUri<'a>>,
258 #[serde(borrow)]
259 pub record: jacquard_common::types::value::Data<'a>,
260 #[serde(borrow)]
261 pub uri: jacquard_common::types::string::AtUri<'a>,
262}
263
264pub mod notification_state {
265
266 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
267 #[allow(unused)]
268 use ::core::marker::PhantomData;
269 mod sealed {
270 pub trait Sealed {}
271 }
272 /// State trait tracking which required fields have been set
273 pub trait State: sealed::Sealed {
274 type IsRead;
275 type Uri;
276 type Reason;
277 type Cid;
278 type IndexedAt;
279 type Author;
280 type Record;
281 }
282 /// Empty state - all required fields are unset
283 pub struct Empty(());
284 impl sealed::Sealed for Empty {}
285 impl State for Empty {
286 type IsRead = Unset;
287 type Uri = Unset;
288 type Reason = Unset;
289 type Cid = Unset;
290 type IndexedAt = Unset;
291 type Author = Unset;
292 type Record = Unset;
293 }
294 ///State transition - sets the `is_read` field to Set
295 pub struct SetIsRead<S: State = Empty>(PhantomData<fn() -> S>);
296 impl<S: State> sealed::Sealed for SetIsRead<S> {}
297 impl<S: State> State for SetIsRead<S> {
298 type IsRead = Set<members::is_read>;
299 type Uri = S::Uri;
300 type Reason = S::Reason;
301 type Cid = S::Cid;
302 type IndexedAt = S::IndexedAt;
303 type Author = S::Author;
304 type Record = S::Record;
305 }
306 ///State transition - sets the `uri` field to Set
307 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
308 impl<S: State> sealed::Sealed for SetUri<S> {}
309 impl<S: State> State for SetUri<S> {
310 type IsRead = S::IsRead;
311 type Uri = Set<members::uri>;
312 type Reason = S::Reason;
313 type Cid = S::Cid;
314 type IndexedAt = S::IndexedAt;
315 type Author = S::Author;
316 type Record = S::Record;
317 }
318 ///State transition - sets the `reason` field to Set
319 pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>);
320 impl<S: State> sealed::Sealed for SetReason<S> {}
321 impl<S: State> State for SetReason<S> {
322 type IsRead = S::IsRead;
323 type Uri = S::Uri;
324 type Reason = Set<members::reason>;
325 type Cid = S::Cid;
326 type IndexedAt = S::IndexedAt;
327 type Author = S::Author;
328 type Record = S::Record;
329 }
330 ///State transition - sets the `cid` field to Set
331 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
332 impl<S: State> sealed::Sealed for SetCid<S> {}
333 impl<S: State> State for SetCid<S> {
334 type IsRead = S::IsRead;
335 type Uri = S::Uri;
336 type Reason = S::Reason;
337 type Cid = Set<members::cid>;
338 type IndexedAt = S::IndexedAt;
339 type Author = S::Author;
340 type Record = S::Record;
341 }
342 ///State transition - sets the `indexed_at` field to Set
343 pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
344 impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
345 impl<S: State> State for SetIndexedAt<S> {
346 type IsRead = S::IsRead;
347 type Uri = S::Uri;
348 type Reason = S::Reason;
349 type Cid = S::Cid;
350 type IndexedAt = Set<members::indexed_at>;
351 type Author = S::Author;
352 type Record = S::Record;
353 }
354 ///State transition - sets the `author` field to Set
355 pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
356 impl<S: State> sealed::Sealed for SetAuthor<S> {}
357 impl<S: State> State for SetAuthor<S> {
358 type IsRead = S::IsRead;
359 type Uri = S::Uri;
360 type Reason = S::Reason;
361 type Cid = S::Cid;
362 type IndexedAt = S::IndexedAt;
363 type Author = Set<members::author>;
364 type Record = S::Record;
365 }
366 ///State transition - sets the `record` field to Set
367 pub struct SetRecord<S: State = Empty>(PhantomData<fn() -> S>);
368 impl<S: State> sealed::Sealed for SetRecord<S> {}
369 impl<S: State> State for SetRecord<S> {
370 type IsRead = S::IsRead;
371 type Uri = S::Uri;
372 type Reason = S::Reason;
373 type Cid = S::Cid;
374 type IndexedAt = S::IndexedAt;
375 type Author = S::Author;
376 type Record = Set<members::record>;
377 }
378 /// Marker types for field names
379 #[allow(non_camel_case_types)]
380 pub mod members {
381 ///Marker type for the `is_read` field
382 pub struct is_read(());
383 ///Marker type for the `uri` field
384 pub struct uri(());
385 ///Marker type for the `reason` field
386 pub struct reason(());
387 ///Marker type for the `cid` field
388 pub struct cid(());
389 ///Marker type for the `indexed_at` field
390 pub struct indexed_at(());
391 ///Marker type for the `author` field
392 pub struct author(());
393 ///Marker type for the `record` field
394 pub struct record(());
395 }
396}
397
398/// Builder for constructing an instance of this type
399pub struct NotificationBuilder<'a, S: notification_state::State> {
400 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
401 __unsafe_private_named: (
402 ::core::option::Option<crate::app_bsky::actor::ProfileView<'a>>,
403 ::core::option::Option<jacquard_common::types::string::Cid<'a>>,
404 ::core::option::Option<jacquard_common::types::string::Datetime>,
405 ::core::option::Option<bool>,
406 ::core::option::Option<Vec<crate::com_atproto::label::Label<'a>>>,
407 ::core::option::Option<NotificationReason<'a>>,
408 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
409 ::core::option::Option<jacquard_common::types::value::Data<'a>>,
410 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
411 ),
412 _phantom: ::core::marker::PhantomData<&'a ()>,
413}
414
415impl<'a> Notification<'a> {
416 /// Create a new builder for this type
417 pub fn new() -> NotificationBuilder<'a, notification_state::Empty> {
418 NotificationBuilder::new()
419 }
420}
421
422impl<'a> NotificationBuilder<'a, notification_state::Empty> {
423 /// Create a new builder with all fields unset
424 pub fn new() -> Self {
425 NotificationBuilder {
426 _phantom_state: ::core::marker::PhantomData,
427 __unsafe_private_named: (
428 None,
429 None,
430 None,
431 None,
432 None,
433 None,
434 None,
435 None,
436 None,
437 ),
438 _phantom: ::core::marker::PhantomData,
439 }
440 }
441}
442
443impl<'a, S> NotificationBuilder<'a, S>
444where
445 S: notification_state::State,
446 S::Author: notification_state::IsUnset,
447{
448 /// Set the `author` field (required)
449 pub fn author(
450 mut self,
451 value: impl Into<crate::app_bsky::actor::ProfileView<'a>>,
452 ) -> NotificationBuilder<'a, notification_state::SetAuthor<S>> {
453 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
454 NotificationBuilder {
455 _phantom_state: ::core::marker::PhantomData,
456 __unsafe_private_named: self.__unsafe_private_named,
457 _phantom: ::core::marker::PhantomData,
458 }
459 }
460}
461
462impl<'a, S> NotificationBuilder<'a, S>
463where
464 S: notification_state::State,
465 S::Cid: notification_state::IsUnset,
466{
467 /// Set the `cid` field (required)
468 pub fn cid(
469 mut self,
470 value: impl Into<jacquard_common::types::string::Cid<'a>>,
471 ) -> NotificationBuilder<'a, notification_state::SetCid<S>> {
472 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
473 NotificationBuilder {
474 _phantom_state: ::core::marker::PhantomData,
475 __unsafe_private_named: self.__unsafe_private_named,
476 _phantom: ::core::marker::PhantomData,
477 }
478 }
479}
480
481impl<'a, S> NotificationBuilder<'a, S>
482where
483 S: notification_state::State,
484 S::IndexedAt: notification_state::IsUnset,
485{
486 /// Set the `indexedAt` field (required)
487 pub fn indexed_at(
488 mut self,
489 value: impl Into<jacquard_common::types::string::Datetime>,
490 ) -> NotificationBuilder<'a, notification_state::SetIndexedAt<S>> {
491 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
492 NotificationBuilder {
493 _phantom_state: ::core::marker::PhantomData,
494 __unsafe_private_named: self.__unsafe_private_named,
495 _phantom: ::core::marker::PhantomData,
496 }
497 }
498}
499
500impl<'a, S> NotificationBuilder<'a, S>
501where
502 S: notification_state::State,
503 S::IsRead: notification_state::IsUnset,
504{
505 /// Set the `isRead` field (required)
506 pub fn is_read(
507 mut self,
508 value: impl Into<bool>,
509 ) -> NotificationBuilder<'a, notification_state::SetIsRead<S>> {
510 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
511 NotificationBuilder {
512 _phantom_state: ::core::marker::PhantomData,
513 __unsafe_private_named: self.__unsafe_private_named,
514 _phantom: ::core::marker::PhantomData,
515 }
516 }
517}
518
519impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
520 /// Set the `labels` field (optional)
521 pub fn labels(
522 mut self,
523 value: impl Into<Option<Vec<crate::com_atproto::label::Label<'a>>>>,
524 ) -> Self {
525 self.__unsafe_private_named.4 = value.into();
526 self
527 }
528 /// Set the `labels` field to an Option value (optional)
529 pub fn maybe_labels(
530 mut self,
531 value: Option<Vec<crate::com_atproto::label::Label<'a>>>,
532 ) -> Self {
533 self.__unsafe_private_named.4 = value;
534 self
535 }
536}
537
538impl<'a, S> NotificationBuilder<'a, S>
539where
540 S: notification_state::State,
541 S::Reason: notification_state::IsUnset,
542{
543 /// Set the `reason` field (required)
544 pub fn reason(
545 mut self,
546 value: impl Into<NotificationReason<'a>>,
547 ) -> NotificationBuilder<'a, notification_state::SetReason<S>> {
548 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
549 NotificationBuilder {
550 _phantom_state: ::core::marker::PhantomData,
551 __unsafe_private_named: self.__unsafe_private_named,
552 _phantom: ::core::marker::PhantomData,
553 }
554 }
555}
556
557impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
558 /// Set the `reasonSubject` field (optional)
559 pub fn reason_subject(
560 mut self,
561 value: impl Into<Option<jacquard_common::types::string::AtUri<'a>>>,
562 ) -> Self {
563 self.__unsafe_private_named.6 = value.into();
564 self
565 }
566 /// Set the `reasonSubject` field to an Option value (optional)
567 pub fn maybe_reason_subject(
568 mut self,
569 value: Option<jacquard_common::types::string::AtUri<'a>>,
570 ) -> Self {
571 self.__unsafe_private_named.6 = value;
572 self
573 }
574}
575
576impl<'a, S> NotificationBuilder<'a, S>
577where
578 S: notification_state::State,
579 S::Record: notification_state::IsUnset,
580{
581 /// Set the `record` field (required)
582 pub fn record(
583 mut self,
584 value: impl Into<jacquard_common::types::value::Data<'a>>,
585 ) -> NotificationBuilder<'a, notification_state::SetRecord<S>> {
586 self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into());
587 NotificationBuilder {
588 _phantom_state: ::core::marker::PhantomData,
589 __unsafe_private_named: self.__unsafe_private_named,
590 _phantom: ::core::marker::PhantomData,
591 }
592 }
593}
594
595impl<'a, S> NotificationBuilder<'a, S>
596where
597 S: notification_state::State,
598 S::Uri: notification_state::IsUnset,
599{
600 /// Set the `uri` field (required)
601 pub fn uri(
602 mut self,
603 value: impl Into<jacquard_common::types::string::AtUri<'a>>,
604 ) -> NotificationBuilder<'a, notification_state::SetUri<S>> {
605 self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into());
606 NotificationBuilder {
607 _phantom_state: ::core::marker::PhantomData,
608 __unsafe_private_named: self.__unsafe_private_named,
609 _phantom: ::core::marker::PhantomData,
610 }
611 }
612}
613
614impl<'a, S> NotificationBuilder<'a, S>
615where
616 S: notification_state::State,
617 S::IsRead: notification_state::IsSet,
618 S::Uri: notification_state::IsSet,
619 S::Reason: notification_state::IsSet,
620 S::Cid: notification_state::IsSet,
621 S::IndexedAt: notification_state::IsSet,
622 S::Author: notification_state::IsSet,
623 S::Record: notification_state::IsSet,
624{
625 /// Build the final struct
626 pub fn build(self) -> Notification<'a> {
627 Notification {
628 author: self.__unsafe_private_named.0.unwrap(),
629 cid: self.__unsafe_private_named.1.unwrap(),
630 indexed_at: self.__unsafe_private_named.2.unwrap(),
631 is_read: self.__unsafe_private_named.3.unwrap(),
632 labels: self.__unsafe_private_named.4,
633 reason: self.__unsafe_private_named.5.unwrap(),
634 reason_subject: self.__unsafe_private_named.6,
635 record: self.__unsafe_private_named.7.unwrap(),
636 uri: self.__unsafe_private_named.8.unwrap(),
637 extra_data: Default::default(),
638 }
639 }
640 /// Build the final struct with custom extra_data
641 pub fn build_with_data(
642 self,
643 extra_data: std::collections::BTreeMap<
644 jacquard_common::smol_str::SmolStr,
645 jacquard_common::types::value::Data<'a>,
646 >,
647 ) -> Notification<'a> {
648 Notification {
649 author: self.__unsafe_private_named.0.unwrap(),
650 cid: self.__unsafe_private_named.1.unwrap(),
651 indexed_at: self.__unsafe_private_named.2.unwrap(),
652 is_read: self.__unsafe_private_named.3.unwrap(),
653 labels: self.__unsafe_private_named.4,
654 reason: self.__unsafe_private_named.5.unwrap(),
655 reason_subject: self.__unsafe_private_named.6,
656 record: self.__unsafe_private_named.7.unwrap(),
657 uri: self.__unsafe_private_named.8.unwrap(),
658 extra_data: Some(extra_data),
659 }
660 }
661}
662
663/// The reason why this notification was delivered - e.g. your post was liked, or you received a new follower.
664#[derive(Debug, Clone, PartialEq, Eq, Hash)]
665pub enum NotificationReason<'a> {
666 Like,
667 Repost,
668 Follow,
669 Mention,
670 Reply,
671 Quote,
672 StarterpackJoined,
673 Verified,
674 Unverified,
675 LikeViaRepost,
676 RepostViaRepost,
677 SubscribedPost,
678 Other(jacquard_common::CowStr<'a>),
679}
680
681impl<'a> NotificationReason<'a> {
682 pub fn as_str(&self) -> &str {
683 match self {
684 Self::Like => "like",
685 Self::Repost => "repost",
686 Self::Follow => "follow",
687 Self::Mention => "mention",
688 Self::Reply => "reply",
689 Self::Quote => "quote",
690 Self::StarterpackJoined => "starterpack-joined",
691 Self::Verified => "verified",
692 Self::Unverified => "unverified",
693 Self::LikeViaRepost => "like-via-repost",
694 Self::RepostViaRepost => "repost-via-repost",
695 Self::SubscribedPost => "subscribed-post",
696 Self::Other(s) => s.as_ref(),
697 }
698 }
699}
700
701impl<'a> From<&'a str> for NotificationReason<'a> {
702 fn from(s: &'a str) -> Self {
703 match s {
704 "like" => Self::Like,
705 "repost" => Self::Repost,
706 "follow" => Self::Follow,
707 "mention" => Self::Mention,
708 "reply" => Self::Reply,
709 "quote" => Self::Quote,
710 "starterpack-joined" => Self::StarterpackJoined,
711 "verified" => Self::Verified,
712 "unverified" => Self::Unverified,
713 "like-via-repost" => Self::LikeViaRepost,
714 "repost-via-repost" => Self::RepostViaRepost,
715 "subscribed-post" => Self::SubscribedPost,
716 _ => Self::Other(jacquard_common::CowStr::from(s)),
717 }
718 }
719}
720
721impl<'a> From<String> for NotificationReason<'a> {
722 fn from(s: String) -> Self {
723 match s.as_str() {
724 "like" => Self::Like,
725 "repost" => Self::Repost,
726 "follow" => Self::Follow,
727 "mention" => Self::Mention,
728 "reply" => Self::Reply,
729 "quote" => Self::Quote,
730 "starterpack-joined" => Self::StarterpackJoined,
731 "verified" => Self::Verified,
732 "unverified" => Self::Unverified,
733 "like-via-repost" => Self::LikeViaRepost,
734 "repost-via-repost" => Self::RepostViaRepost,
735 "subscribed-post" => Self::SubscribedPost,
736 _ => Self::Other(jacquard_common::CowStr::from(s)),
737 }
738 }
739}
740
741impl<'a> core::fmt::Display for NotificationReason<'a> {
742 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
743 write!(f, "{}", self.as_str())
744 }
745}
746
747impl<'a> AsRef<str> for NotificationReason<'a> {
748 fn as_ref(&self) -> &str {
749 self.as_str()
750 }
751}
752
753impl<'a> serde::Serialize for NotificationReason<'a> {
754 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
755 where
756 S: serde::Serializer,
757 {
758 serializer.serialize_str(self.as_str())
759 }
760}
761
762impl<'de, 'a> serde::Deserialize<'de> for NotificationReason<'a>
763where
764 'de: 'a,
765{
766 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
767 where
768 D: serde::Deserializer<'de>,
769 {
770 let s = <&'de str>::deserialize(deserializer)?;
771 Ok(Self::from(s))
772 }
773}
774
775impl<'a> Default for NotificationReason<'a> {
776 fn default() -> Self {
777 Self::Other(Default::default())
778 }
779}
780
781impl jacquard_common::IntoStatic for NotificationReason<'_> {
782 type Output = NotificationReason<'static>;
783 fn into_static(self) -> Self::Output {
784 match self {
785 NotificationReason::Like => NotificationReason::Like,
786 NotificationReason::Repost => NotificationReason::Repost,
787 NotificationReason::Follow => NotificationReason::Follow,
788 NotificationReason::Mention => NotificationReason::Mention,
789 NotificationReason::Reply => NotificationReason::Reply,
790 NotificationReason::Quote => NotificationReason::Quote,
791 NotificationReason::StarterpackJoined => {
792 NotificationReason::StarterpackJoined
793 }
794 NotificationReason::Verified => NotificationReason::Verified,
795 NotificationReason::Unverified => NotificationReason::Unverified,
796 NotificationReason::LikeViaRepost => NotificationReason::LikeViaRepost,
797 NotificationReason::RepostViaRepost => NotificationReason::RepostViaRepost,
798 NotificationReason::SubscribedPost => NotificationReason::SubscribedPost,
799 NotificationReason::Other(v) => NotificationReason::Other(v.into_static()),
800 }
801 }
802}
803
804fn lexicon_doc_app_bsky_notification_listNotifications() -> ::jacquard_lexicon::lexicon::LexiconDoc<
805 'static,
806> {
807 ::jacquard_lexicon::lexicon::LexiconDoc {
808 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
809 id: ::jacquard_common::CowStr::new_static(
810 "app.bsky.notification.listNotifications",
811 ),
812 revision: None,
813 description: None,
814 defs: {
815 let mut map = ::alloc::collections::BTreeMap::new();
816 map.insert(
817 ::jacquard_common::smol_str::SmolStr::new_static("main"),
818 ::jacquard_lexicon::lexicon::LexUserType::XrpcQuery(::jacquard_lexicon::lexicon::LexXrpcQuery {
819 description: None,
820 parameters: Some(
821 ::jacquard_lexicon::lexicon::LexXrpcQueryParameter::Params(::jacquard_lexicon::lexicon::LexXrpcParameters {
822 description: None,
823 required: None,
824 properties: {
825 #[allow(unused_mut)]
826 let mut map = ::alloc::collections::BTreeMap::new();
827 map.insert(
828 ::jacquard_common::smol_str::SmolStr::new_static("cursor"),
829 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::String(::jacquard_lexicon::lexicon::LexString {
830 description: None,
831 format: None,
832 default: None,
833 min_length: None,
834 max_length: None,
835 min_graphemes: None,
836 max_graphemes: None,
837 r#enum: None,
838 r#const: None,
839 known_values: None,
840 }),
841 );
842 map.insert(
843 ::jacquard_common::smol_str::SmolStr::new_static("limit"),
844 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
845 description: None,
846 default: None,
847 minimum: None,
848 maximum: None,
849 r#enum: None,
850 r#const: None,
851 }),
852 );
853 map.insert(
854 ::jacquard_common::smol_str::SmolStr::new_static(
855 "priority",
856 ),
857 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
858 description: None,
859 default: None,
860 r#const: None,
861 }),
862 );
863 map.insert(
864 ::jacquard_common::smol_str::SmolStr::new_static("reasons"),
865 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::Array(::jacquard_lexicon::lexicon::LexPrimitiveArray {
866 description: None,
867 items: ::jacquard_lexicon::lexicon::LexPrimitiveArrayItem::String(::jacquard_lexicon::lexicon::LexString {
868 description: Some(
869 ::jacquard_common::CowStr::new_static(
870 "A reason that matches the reason property of #notification.",
871 ),
872 ),
873 format: None,
874 default: None,
875 min_length: None,
876 max_length: None,
877 min_graphemes: None,
878 max_graphemes: None,
879 r#enum: None,
880 r#const: None,
881 known_values: None,
882 }),
883 min_length: None,
884 max_length: None,
885 }),
886 );
887 map.insert(
888 ::jacquard_common::smol_str::SmolStr::new_static("seenAt"),
889 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::String(::jacquard_lexicon::lexicon::LexString {
890 description: None,
891 format: Some(
892 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
893 ),
894 default: None,
895 min_length: None,
896 max_length: None,
897 min_graphemes: None,
898 max_graphemes: None,
899 r#enum: None,
900 r#const: None,
901 known_values: None,
902 }),
903 );
904 map
905 },
906 }),
907 ),
908 output: None,
909 errors: None,
910 }),
911 );
912 map.insert(
913 ::jacquard_common::smol_str::SmolStr::new_static("notification"),
914 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
915 description: None,
916 required: Some(
917 vec![
918 ::jacquard_common::smol_str::SmolStr::new_static("uri"),
919 ::jacquard_common::smol_str::SmolStr::new_static("cid"),
920 ::jacquard_common::smol_str::SmolStr::new_static("author"),
921 ::jacquard_common::smol_str::SmolStr::new_static("reason"),
922 ::jacquard_common::smol_str::SmolStr::new_static("record"),
923 ::jacquard_common::smol_str::SmolStr::new_static("isRead"),
924 ::jacquard_common::smol_str::SmolStr::new_static("indexedAt")
925 ],
926 ),
927 nullable: None,
928 properties: {
929 #[allow(unused_mut)]
930 let mut map = ::alloc::collections::BTreeMap::new();
931 map.insert(
932 ::jacquard_common::smol_str::SmolStr::new_static("author"),
933 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
934 description: None,
935 r#ref: ::jacquard_common::CowStr::new_static(
936 "app.bsky.actor.defs#profileView",
937 ),
938 }),
939 );
940 map.insert(
941 ::jacquard_common::smol_str::SmolStr::new_static("cid"),
942 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
943 description: None,
944 format: Some(
945 ::jacquard_lexicon::lexicon::LexStringFormat::Cid,
946 ),
947 default: None,
948 min_length: None,
949 max_length: None,
950 min_graphemes: None,
951 max_graphemes: None,
952 r#enum: None,
953 r#const: None,
954 known_values: None,
955 }),
956 );
957 map.insert(
958 ::jacquard_common::smol_str::SmolStr::new_static(
959 "indexedAt",
960 ),
961 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
962 description: None,
963 format: Some(
964 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
965 ),
966 default: None,
967 min_length: None,
968 max_length: None,
969 min_graphemes: None,
970 max_graphemes: None,
971 r#enum: None,
972 r#const: None,
973 known_values: None,
974 }),
975 );
976 map.insert(
977 ::jacquard_common::smol_str::SmolStr::new_static("isRead"),
978 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
979 description: None,
980 default: None,
981 r#const: None,
982 }),
983 );
984 map.insert(
985 ::jacquard_common::smol_str::SmolStr::new_static("labels"),
986 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
987 description: None,
988 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
989 description: None,
990 r#ref: ::jacquard_common::CowStr::new_static(
991 "com.atproto.label.defs#label",
992 ),
993 }),
994 min_length: None,
995 max_length: None,
996 }),
997 );
998 map.insert(
999 ::jacquard_common::smol_str::SmolStr::new_static("reason"),
1000 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
1001 description: Some(
1002 ::jacquard_common::CowStr::new_static(
1003 "The reason why this notification was delivered - e.g. your post was liked, or you received a new follower.",
1004 ),
1005 ),
1006 format: None,
1007 default: None,
1008 min_length: None,
1009 max_length: None,
1010 min_graphemes: None,
1011 max_graphemes: None,
1012 r#enum: None,
1013 r#const: None,
1014 known_values: None,
1015 }),
1016 );
1017 map.insert(
1018 ::jacquard_common::smol_str::SmolStr::new_static(
1019 "reasonSubject",
1020 ),
1021 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
1022 description: None,
1023 format: Some(
1024 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
1025 ),
1026 default: None,
1027 min_length: None,
1028 max_length: None,
1029 min_graphemes: None,
1030 max_graphemes: None,
1031 r#enum: None,
1032 r#const: None,
1033 known_values: None,
1034 }),
1035 );
1036 map.insert(
1037 ::jacquard_common::smol_str::SmolStr::new_static("record"),
1038 ::jacquard_lexicon::lexicon::LexObjectProperty::Unknown(::jacquard_lexicon::lexicon::LexUnknown {
1039 description: None,
1040 }),
1041 );
1042 map.insert(
1043 ::jacquard_common::smol_str::SmolStr::new_static("uri"),
1044 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
1045 description: None,
1046 format: Some(
1047 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
1048 ),
1049 default: None,
1050 min_length: None,
1051 max_length: None,
1052 min_graphemes: None,
1053 max_graphemes: None,
1054 r#enum: None,
1055 r#const: None,
1056 known_values: None,
1057 }),
1058 );
1059 map
1060 },
1061 }),
1062 );
1063 map
1064 },
1065 }
1066}
1067
1068impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Notification<'a> {
1069 fn nsid() -> &'static str {
1070 "app.bsky.notification.listNotifications"
1071 }
1072 fn def_name() -> &'static str {
1073 "notification"
1074 }
1075 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1076 lexicon_doc_app_bsky_notification_listNotifications()
1077 }
1078 fn validate(
1079 &self,
1080 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1081 Ok(())
1082 }
1083}