jacquard_api/app_bsky/notification/
declaration.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.notification.declaration
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// A declaration of the user's choices related to notifications that can be produced by them.
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 Declaration<'a> {
21    /// A declaration of the user's preference for allowing activity subscriptions from other users. Absence of a record implies 'followers'.
22    #[serde(borrow)]
23    pub allow_subscriptions: jacquard_common::CowStr<'a>,
24}
25
26pub mod declaration_state {
27
28    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
29    #[allow(unused)]
30    use ::core::marker::PhantomData;
31    mod sealed {
32        pub trait Sealed {}
33    }
34    /// State trait tracking which required fields have been set
35    pub trait State: sealed::Sealed {
36        type AllowSubscriptions;
37    }
38    /// Empty state - all required fields are unset
39    pub struct Empty(());
40    impl sealed::Sealed for Empty {}
41    impl State for Empty {
42        type AllowSubscriptions = Unset;
43    }
44    ///State transition - sets the `allow_subscriptions` field to Set
45    pub struct SetAllowSubscriptions<S: State = Empty>(PhantomData<fn() -> S>);
46    impl<S: State> sealed::Sealed for SetAllowSubscriptions<S> {}
47    impl<S: State> State for SetAllowSubscriptions<S> {
48        type AllowSubscriptions = Set<members::allow_subscriptions>;
49    }
50    /// Marker types for field names
51    #[allow(non_camel_case_types)]
52    pub mod members {
53        ///Marker type for the `allow_subscriptions` field
54        pub struct allow_subscriptions(());
55    }
56}
57
58/// Builder for constructing an instance of this type
59pub struct DeclarationBuilder<'a, S: declaration_state::State> {
60    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
61    __unsafe_private_named: (::core::option::Option<jacquard_common::CowStr<'a>>,),
62    _phantom: ::core::marker::PhantomData<&'a ()>,
63}
64
65impl<'a> Declaration<'a> {
66    /// Create a new builder for this type
67    pub fn new() -> DeclarationBuilder<'a, declaration_state::Empty> {
68        DeclarationBuilder::new()
69    }
70}
71
72impl<'a> DeclarationBuilder<'a, declaration_state::Empty> {
73    /// Create a new builder with all fields unset
74    pub fn new() -> Self {
75        DeclarationBuilder {
76            _phantom_state: ::core::marker::PhantomData,
77            __unsafe_private_named: (None,),
78            _phantom: ::core::marker::PhantomData,
79        }
80    }
81}
82
83impl<'a, S> DeclarationBuilder<'a, S>
84where
85    S: declaration_state::State,
86    S::AllowSubscriptions: declaration_state::IsUnset,
87{
88    /// Set the `allowSubscriptions` field (required)
89    pub fn allow_subscriptions(
90        mut self,
91        value: impl Into<jacquard_common::CowStr<'a>>,
92    ) -> DeclarationBuilder<'a, declaration_state::SetAllowSubscriptions<S>> {
93        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
94        DeclarationBuilder {
95            _phantom_state: ::core::marker::PhantomData,
96            __unsafe_private_named: self.__unsafe_private_named,
97            _phantom: ::core::marker::PhantomData,
98        }
99    }
100}
101
102impl<'a, S> DeclarationBuilder<'a, S>
103where
104    S: declaration_state::State,
105    S::AllowSubscriptions: declaration_state::IsSet,
106{
107    /// Build the final struct
108    pub fn build(self) -> Declaration<'a> {
109        Declaration {
110            allow_subscriptions: self.__unsafe_private_named.0.unwrap(),
111            extra_data: Default::default(),
112        }
113    }
114    /// Build the final struct with custom extra_data
115    pub fn build_with_data(
116        self,
117        extra_data: std::collections::BTreeMap<
118            jacquard_common::smol_str::SmolStr,
119            jacquard_common::types::value::Data<'a>,
120        >,
121    ) -> Declaration<'a> {
122        Declaration {
123            allow_subscriptions: self.__unsafe_private_named.0.unwrap(),
124            extra_data: Some(extra_data),
125        }
126    }
127}
128
129impl<'a> Declaration<'a> {
130    pub fn uri(
131        uri: impl Into<jacquard_common::CowStr<'a>>,
132    ) -> Result<
133        jacquard_common::types::uri::RecordUri<'a, DeclarationRecord>,
134        jacquard_common::types::uri::UriError,
135    > {
136        jacquard_common::types::uri::RecordUri::try_from_uri(
137            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
138        )
139    }
140}
141
142/// Typed wrapper for GetRecord response with this collection's record type.
143#[derive(
144    serde::Serialize,
145    serde::Deserialize,
146    Debug,
147    Clone,
148    PartialEq,
149    Eq,
150    jacquard_derive::IntoStatic
151)]
152#[serde(rename_all = "camelCase")]
153pub struct DeclarationGetRecordOutput<'a> {
154    #[serde(skip_serializing_if = "std::option::Option::is_none")]
155    #[serde(borrow)]
156    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
157    #[serde(borrow)]
158    pub uri: jacquard_common::types::string::AtUri<'a>,
159    #[serde(borrow)]
160    pub value: Declaration<'a>,
161}
162
163impl From<DeclarationGetRecordOutput<'_>> for Declaration<'_> {
164    fn from(output: DeclarationGetRecordOutput<'_>) -> Self {
165        use jacquard_common::IntoStatic;
166        output.value.into_static()
167    }
168}
169
170impl jacquard_common::types::collection::Collection for Declaration<'_> {
171    const NSID: &'static str = "app.bsky.notification.declaration";
172    type Record = DeclarationRecord;
173}
174
175/// Marker type for deserializing records from this collection.
176#[derive(Debug, serde::Serialize, serde::Deserialize)]
177pub struct DeclarationRecord;
178impl jacquard_common::xrpc::XrpcResp for DeclarationRecord {
179    const NSID: &'static str = "app.bsky.notification.declaration";
180    const ENCODING: &'static str = "application/json";
181    type Output<'de> = DeclarationGetRecordOutput<'de>;
182    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
183}
184
185impl jacquard_common::types::collection::Collection for DeclarationRecord {
186    const NSID: &'static str = "app.bsky.notification.declaration";
187    type Record = DeclarationRecord;
188}
189
190impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Declaration<'a> {
191    fn nsid() -> &'static str {
192        "app.bsky.notification.declaration"
193    }
194    fn def_name() -> &'static str {
195        "main"
196    }
197    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
198        lexicon_doc_app_bsky_notification_declaration()
199    }
200    fn validate(
201        &self,
202    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
203        Ok(())
204    }
205}
206
207fn lexicon_doc_app_bsky_notification_declaration() -> ::jacquard_lexicon::lexicon::LexiconDoc<
208    'static,
209> {
210    ::jacquard_lexicon::lexicon::LexiconDoc {
211        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
212        id: ::jacquard_common::CowStr::new_static("app.bsky.notification.declaration"),
213        revision: None,
214        description: None,
215        defs: {
216            let mut map = ::std::collections::BTreeMap::new();
217            map.insert(
218                ::jacquard_common::smol_str::SmolStr::new_static("main"),
219                ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
220                    description: Some(
221                        ::jacquard_common::CowStr::new_static(
222                            "A declaration of the user's choices related to notifications that can be produced by them.",
223                        ),
224                    ),
225                    key: Some(::jacquard_common::CowStr::new_static("literal:self")),
226                    record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
227                        description: None,
228                        required: Some(
229                            vec![
230                                ::jacquard_common::smol_str::SmolStr::new_static("allowSubscriptions")
231                            ],
232                        ),
233                        nullable: None,
234                        properties: {
235                            #[allow(unused_mut)]
236                            let mut map = ::std::collections::BTreeMap::new();
237                            map.insert(
238                                ::jacquard_common::smol_str::SmolStr::new_static(
239                                    "allowSubscriptions",
240                                ),
241                                ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
242                                    description: Some(
243                                        ::jacquard_common::CowStr::new_static(
244                                            "A declaration of the user's preference for allowing activity subscriptions from other users. Absence of a record implies 'followers'.",
245                                        ),
246                                    ),
247                                    format: None,
248                                    default: None,
249                                    min_length: None,
250                                    max_length: None,
251                                    min_graphemes: None,
252                                    max_graphemes: None,
253                                    r#enum: None,
254                                    r#const: None,
255                                    known_values: None,
256                                }),
257                            );
258                            map
259                        },
260                    }),
261                }),
262            );
263            map
264        },
265    }
266}