atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.feed.like
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Record declaring a 'like' of a piece of subject content.
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 Like<'a> {
21 pub created_at: jacquard_common::types::string::Datetime,
22 #[serde(borrow)]
23 pub subject: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
24 #[serde(skip_serializing_if = "std::option::Option::is_none")]
25 #[serde(borrow)]
26 pub via: std::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
27}
28
29pub mod like_state {
30
31 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
32 #[allow(unused)]
33 use ::core::marker::PhantomData;
34 mod sealed {
35 pub trait Sealed {}
36 }
37 /// State trait tracking which required fields have been set
38 pub trait State: sealed::Sealed {
39 type CreatedAt;
40 type Subject;
41 }
42 /// Empty state - all required fields are unset
43 pub struct Empty(());
44 impl sealed::Sealed for Empty {}
45 impl State for Empty {
46 type CreatedAt = Unset;
47 type Subject = Unset;
48 }
49 ///State transition - sets the `created_at` field to Set
50 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
51 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
52 impl<S: State> State for SetCreatedAt<S> {
53 type CreatedAt = Set<members::created_at>;
54 type Subject = S::Subject;
55 }
56 ///State transition - sets the `subject` field to Set
57 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
58 impl<S: State> sealed::Sealed for SetSubject<S> {}
59 impl<S: State> State for SetSubject<S> {
60 type CreatedAt = S::CreatedAt;
61 type Subject = Set<members::subject>;
62 }
63 /// Marker types for field names
64 #[allow(non_camel_case_types)]
65 pub mod members {
66 ///Marker type for the `created_at` field
67 pub struct created_at(());
68 ///Marker type for the `subject` field
69 pub struct subject(());
70 }
71}
72
73/// Builder for constructing an instance of this type
74pub struct LikeBuilder<'a, S: like_state::State> {
75 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
76 __unsafe_private_named: (
77 ::core::option::Option<jacquard_common::types::string::Datetime>,
78 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
79 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
80 ),
81 _phantom: ::core::marker::PhantomData<&'a ()>,
82}
83
84impl<'a> Like<'a> {
85 /// Create a new builder for this type
86 pub fn new() -> LikeBuilder<'a, like_state::Empty> {
87 LikeBuilder::new()
88 }
89}
90
91impl<'a> LikeBuilder<'a, like_state::Empty> {
92 /// Create a new builder with all fields unset
93 pub fn new() -> Self {
94 LikeBuilder {
95 _phantom_state: ::core::marker::PhantomData,
96 __unsafe_private_named: (None, None, None),
97 _phantom: ::core::marker::PhantomData,
98 }
99 }
100}
101
102impl<'a, S> LikeBuilder<'a, S>
103where
104 S: like_state::State,
105 S::CreatedAt: like_state::IsUnset,
106{
107 /// Set the `createdAt` field (required)
108 pub fn created_at(
109 mut self,
110 value: impl Into<jacquard_common::types::string::Datetime>,
111 ) -> LikeBuilder<'a, like_state::SetCreatedAt<S>> {
112 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
113 LikeBuilder {
114 _phantom_state: ::core::marker::PhantomData,
115 __unsafe_private_named: self.__unsafe_private_named,
116 _phantom: ::core::marker::PhantomData,
117 }
118 }
119}
120
121impl<'a, S> LikeBuilder<'a, S>
122where
123 S: like_state::State,
124 S::Subject: like_state::IsUnset,
125{
126 /// Set the `subject` field (required)
127 pub fn subject(
128 mut self,
129 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
130 ) -> LikeBuilder<'a, like_state::SetSubject<S>> {
131 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
132 LikeBuilder {
133 _phantom_state: ::core::marker::PhantomData,
134 __unsafe_private_named: self.__unsafe_private_named,
135 _phantom: ::core::marker::PhantomData,
136 }
137 }
138}
139
140impl<'a, S: like_state::State> LikeBuilder<'a, S> {
141 /// Set the `via` field (optional)
142 pub fn via(
143 mut self,
144 value: impl Into<Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
145 ) -> Self {
146 self.__unsafe_private_named.2 = value.into();
147 self
148 }
149 /// Set the `via` field to an Option value (optional)
150 pub fn maybe_via(
151 mut self,
152 value: Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
153 ) -> Self {
154 self.__unsafe_private_named.2 = value;
155 self
156 }
157}
158
159impl<'a, S> LikeBuilder<'a, S>
160where
161 S: like_state::State,
162 S::CreatedAt: like_state::IsSet,
163 S::Subject: like_state::IsSet,
164{
165 /// Build the final struct
166 pub fn build(self) -> Like<'a> {
167 Like {
168 created_at: self.__unsafe_private_named.0.unwrap(),
169 subject: self.__unsafe_private_named.1.unwrap(),
170 via: self.__unsafe_private_named.2,
171 extra_data: Default::default(),
172 }
173 }
174 /// Build the final struct with custom extra_data
175 pub fn build_with_data(
176 self,
177 extra_data: std::collections::BTreeMap<
178 jacquard_common::smol_str::SmolStr,
179 jacquard_common::types::value::Data<'a>,
180 >,
181 ) -> Like<'a> {
182 Like {
183 created_at: self.__unsafe_private_named.0.unwrap(),
184 subject: self.__unsafe_private_named.1.unwrap(),
185 via: self.__unsafe_private_named.2,
186 extra_data: Some(extra_data),
187 }
188 }
189}
190
191impl<'a> Like<'a> {
192 pub fn uri(
193 uri: impl Into<jacquard_common::CowStr<'a>>,
194 ) -> Result<
195 jacquard_common::types::uri::RecordUri<'a, LikeRecord>,
196 jacquard_common::types::uri::UriError,
197 > {
198 jacquard_common::types::uri::RecordUri::try_from_uri(
199 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
200 )
201 }
202}
203
204/// Typed wrapper for GetRecord response with this collection's record type.
205#[derive(
206 serde::Serialize,
207 serde::Deserialize,
208 Debug,
209 Clone,
210 PartialEq,
211 Eq,
212 jacquard_derive::IntoStatic
213)]
214#[serde(rename_all = "camelCase")]
215pub struct LikeGetRecordOutput<'a> {
216 #[serde(skip_serializing_if = "std::option::Option::is_none")]
217 #[serde(borrow)]
218 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
219 #[serde(borrow)]
220 pub uri: jacquard_common::types::string::AtUri<'a>,
221 #[serde(borrow)]
222 pub value: Like<'a>,
223}
224
225impl From<LikeGetRecordOutput<'_>> for Like<'_> {
226 fn from(output: LikeGetRecordOutput<'_>) -> Self {
227 use jacquard_common::IntoStatic;
228 output.value.into_static()
229 }
230}
231
232impl jacquard_common::types::collection::Collection for Like<'_> {
233 const NSID: &'static str = "app.bsky.feed.like";
234 type Record = LikeRecord;
235}
236
237/// Marker type for deserializing records from this collection.
238#[derive(Debug, serde::Serialize, serde::Deserialize)]
239pub struct LikeRecord;
240impl jacquard_common::xrpc::XrpcResp for LikeRecord {
241 const NSID: &'static str = "app.bsky.feed.like";
242 const ENCODING: &'static str = "application/json";
243 type Output<'de> = LikeGetRecordOutput<'de>;
244 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
245}
246
247impl jacquard_common::types::collection::Collection for LikeRecord {
248 const NSID: &'static str = "app.bsky.feed.like";
249 type Record = LikeRecord;
250}
251
252impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Like<'a> {
253 fn nsid() -> &'static str {
254 "app.bsky.feed.like"
255 }
256 fn def_name() -> &'static str {
257 "main"
258 }
259 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
260 lexicon_doc_app_bsky_feed_like()
261 }
262 fn validate(
263 &self,
264 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
265 Ok(())
266 }
267}
268
269fn lexicon_doc_app_bsky_feed_like() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
270 ::jacquard_lexicon::lexicon::LexiconDoc {
271 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
272 id: ::jacquard_common::CowStr::new_static("app.bsky.feed.like"),
273 revision: None,
274 description: None,
275 defs: {
276 let mut map = ::alloc::collections::BTreeMap::new();
277 map.insert(
278 ::jacquard_common::smol_str::SmolStr::new_static("main"),
279 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
280 description: Some(
281 ::jacquard_common::CowStr::new_static(
282 "Record declaring a 'like' of a piece of subject content.",
283 ),
284 ),
285 key: Some(::jacquard_common::CowStr::new_static("tid")),
286 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
287 description: None,
288 required: Some(
289 vec![
290 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
291 ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
292 ],
293 ),
294 nullable: None,
295 properties: {
296 #[allow(unused_mut)]
297 let mut map = ::alloc::collections::BTreeMap::new();
298 map.insert(
299 ::jacquard_common::smol_str::SmolStr::new_static(
300 "createdAt",
301 ),
302 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
303 description: None,
304 format: Some(
305 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
306 ),
307 default: None,
308 min_length: None,
309 max_length: None,
310 min_graphemes: None,
311 max_graphemes: None,
312 r#enum: None,
313 r#const: None,
314 known_values: None,
315 }),
316 );
317 map.insert(
318 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
319 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
320 description: None,
321 r#ref: ::jacquard_common::CowStr::new_static(
322 "com.atproto.repo.strongRef",
323 ),
324 }),
325 );
326 map.insert(
327 ::jacquard_common::smol_str::SmolStr::new_static("via"),
328 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
329 description: None,
330 r#ref: ::jacquard_common::CowStr::new_static(
331 "com.atproto.repo.strongRef",
332 ),
333 }),
334 );
335 map
336 },
337 }),
338 }),
339 );
340 map
341 },
342 }
343}