jacquard_api/chat_bsky/convo/
send_message_batch.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_derive::{IntoStatic, lexicon};
18use jacquard_lexicon::lexicon::LexiconDoc;
19use jacquard_lexicon::schema::LexiconSchema;
20
21#[allow(unused_imports)]
22use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
23use serde::{Serialize, Deserialize};
24use crate::chat_bsky::convo::MessageInput;
25use crate::chat_bsky::convo::MessageView;
26use crate::chat_bsky::convo::send_message_batch;
27
28#[lexicon]
29#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
30#[serde(rename_all = "camelCase")]
31pub struct BatchItem<'a> {
32 #[serde(borrow)]
33 pub convo_id: CowStr<'a>,
34 #[serde(borrow)]
35 pub message: MessageInput<'a>,
36}
37
38
39#[lexicon]
40#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
41#[serde(rename_all = "camelCase")]
42pub struct SendMessageBatch<'a> {
43 #[serde(borrow)]
44 pub items: Vec<send_message_batch::BatchItem<'a>>,
45}
46
47
48#[lexicon]
49#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
50#[serde(rename_all = "camelCase")]
51pub struct SendMessageBatchOutput<'a> {
52 #[serde(borrow)]
53 pub items: Vec<MessageView<'a>>,
54}
55
56impl<'a> LexiconSchema for BatchItem<'a> {
57 fn nsid() -> &'static str {
58 "chat.bsky.convo.sendMessageBatch"
59 }
60 fn def_name() -> &'static str {
61 "batchItem"
62 }
63 fn lexicon_doc() -> LexiconDoc<'static> {
64 lexicon_doc_chat_bsky_convo_sendMessageBatch()
65 }
66 fn validate(&self) -> Result<(), ConstraintError> {
67 Ok(())
68 }
69}
70
71pub struct SendMessageBatchResponse;
73impl jacquard_common::xrpc::XrpcResp for SendMessageBatchResponse {
74 const NSID: &'static str = "chat.bsky.convo.sendMessageBatch";
75 const ENCODING: &'static str = "application/json";
76 type Output<'de> = SendMessageBatchOutput<'de>;
77 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
78}
79
80impl<'a> jacquard_common::xrpc::XrpcRequest for SendMessageBatch<'a> {
81 const NSID: &'static str = "chat.bsky.convo.sendMessageBatch";
82 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
83 "application/json",
84 );
85 type Response = SendMessageBatchResponse;
86}
87
88pub struct SendMessageBatchRequest;
90impl jacquard_common::xrpc::XrpcEndpoint for SendMessageBatchRequest {
91 const PATH: &'static str = "/xrpc/chat.bsky.convo.sendMessageBatch";
92 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
93 "application/json",
94 );
95 type Request<'de> = SendMessageBatch<'de>;
96 type Response = SendMessageBatchResponse;
97}
98
99pub mod batch_item_state {
100
101 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
102 #[allow(unused)]
103 use ::core::marker::PhantomData;
104 mod sealed {
105 pub trait Sealed {}
106 }
107 pub trait State: sealed::Sealed {
109 type ConvoId;
110 type Message;
111 }
112 pub struct Empty(());
114 impl sealed::Sealed for Empty {}
115 impl State for Empty {
116 type ConvoId = Unset;
117 type Message = Unset;
118 }
119 pub struct SetConvoId<S: State = Empty>(PhantomData<fn() -> S>);
121 impl<S: State> sealed::Sealed for SetConvoId<S> {}
122 impl<S: State> State for SetConvoId<S> {
123 type ConvoId = Set<members::convo_id>;
124 type Message = S::Message;
125 }
126 pub struct SetMessage<S: State = Empty>(PhantomData<fn() -> S>);
128 impl<S: State> sealed::Sealed for SetMessage<S> {}
129 impl<S: State> State for SetMessage<S> {
130 type ConvoId = S::ConvoId;
131 type Message = Set<members::message>;
132 }
133 #[allow(non_camel_case_types)]
135 pub mod members {
136 pub struct convo_id(());
138 pub struct message(());
140 }
141}
142
143pub struct BatchItemBuilder<'a, S: batch_item_state::State> {
145 _state: PhantomData<fn() -> S>,
146 _fields: (Option<CowStr<'a>>, Option<MessageInput<'a>>),
147 _lifetime: PhantomData<&'a ()>,
148}
149
150impl<'a> BatchItem<'a> {
151 pub fn new() -> BatchItemBuilder<'a, batch_item_state::Empty> {
153 BatchItemBuilder::new()
154 }
155}
156
157impl<'a> BatchItemBuilder<'a, batch_item_state::Empty> {
158 pub fn new() -> Self {
160 BatchItemBuilder {
161 _state: PhantomData,
162 _fields: (None, None),
163 _lifetime: PhantomData,
164 }
165 }
166}
167
168impl<'a, S> BatchItemBuilder<'a, S>
169where
170 S: batch_item_state::State,
171 S::ConvoId: batch_item_state::IsUnset,
172{
173 pub fn convo_id(
175 mut self,
176 value: impl Into<CowStr<'a>>,
177 ) -> BatchItemBuilder<'a, batch_item_state::SetConvoId<S>> {
178 self._fields.0 = Option::Some(value.into());
179 BatchItemBuilder {
180 _state: PhantomData,
181 _fields: self._fields,
182 _lifetime: PhantomData,
183 }
184 }
185}
186
187impl<'a, S> BatchItemBuilder<'a, S>
188where
189 S: batch_item_state::State,
190 S::Message: batch_item_state::IsUnset,
191{
192 pub fn message(
194 mut self,
195 value: impl Into<MessageInput<'a>>,
196 ) -> BatchItemBuilder<'a, batch_item_state::SetMessage<S>> {
197 self._fields.1 = Option::Some(value.into());
198 BatchItemBuilder {
199 _state: PhantomData,
200 _fields: self._fields,
201 _lifetime: PhantomData,
202 }
203 }
204}
205
206impl<'a, S> BatchItemBuilder<'a, S>
207where
208 S: batch_item_state::State,
209 S::ConvoId: batch_item_state::IsSet,
210 S::Message: batch_item_state::IsSet,
211{
212 pub fn build(self) -> BatchItem<'a> {
214 BatchItem {
215 convo_id: self._fields.0.unwrap(),
216 message: self._fields.1.unwrap(),
217 extra_data: Default::default(),
218 }
219 }
220 pub fn build_with_data(
222 self,
223 extra_data: BTreeMap<
224 jacquard_common::deps::smol_str::SmolStr,
225 jacquard_common::types::value::Data<'a>,
226 >,
227 ) -> BatchItem<'a> {
228 BatchItem {
229 convo_id: self._fields.0.unwrap(),
230 message: self._fields.1.unwrap(),
231 extra_data: Some(extra_data),
232 }
233 }
234}
235
236fn lexicon_doc_chat_bsky_convo_sendMessageBatch() -> LexiconDoc<'static> {
237 #[allow(unused_imports)]
238 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
239 use jacquard_lexicon::lexicon::*;
240 use alloc::collections::BTreeMap;
241 LexiconDoc {
242 lexicon: Lexicon::Lexicon1,
243 id: CowStr::new_static("chat.bsky.convo.sendMessageBatch"),
244 defs: {
245 let mut map = BTreeMap::new();
246 map.insert(
247 SmolStr::new_static("batchItem"),
248 LexUserType::Object(LexObject {
249 required: Some(
250 vec![
251 SmolStr::new_static("convoId"),
252 SmolStr::new_static("message")
253 ],
254 ),
255 properties: {
256 #[allow(unused_mut)]
257 let mut map = BTreeMap::new();
258 map.insert(
259 SmolStr::new_static("convoId"),
260 LexObjectProperty::String(LexString { ..Default::default() }),
261 );
262 map.insert(
263 SmolStr::new_static("message"),
264 LexObjectProperty::Ref(LexRef {
265 r#ref: CowStr::new_static(
266 "chat.bsky.convo.defs#messageInput",
267 ),
268 ..Default::default()
269 }),
270 );
271 map
272 },
273 ..Default::default()
274 }),
275 );
276 map.insert(
277 SmolStr::new_static("main"),
278 LexUserType::XrpcProcedure(LexXrpcProcedure {
279 input: Some(LexXrpcBody {
280 encoding: CowStr::new_static("application/json"),
281 schema: Some(
282 LexXrpcBodySchema::Object(LexObject {
283 required: Some(vec![SmolStr::new_static("items")]),
284 properties: {
285 #[allow(unused_mut)]
286 let mut map = BTreeMap::new();
287 map.insert(
288 SmolStr::new_static("items"),
289 LexObjectProperty::Array(LexArray {
290 items: LexArrayItem::Ref(LexRef {
291 r#ref: CowStr::new_static("#batchItem"),
292 ..Default::default()
293 }),
294 max_length: Some(100usize),
295 ..Default::default()
296 }),
297 );
298 map
299 },
300 ..Default::default()
301 }),
302 ),
303 ..Default::default()
304 }),
305 ..Default::default()
306 }),
307 );
308 map
309 },
310 ..Default::default()
311 }
312}
313
314pub mod send_message_batch_state {
315
316 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
317 #[allow(unused)]
318 use ::core::marker::PhantomData;
319 mod sealed {
320 pub trait Sealed {}
321 }
322 pub trait State: sealed::Sealed {
324 type Items;
325 }
326 pub struct Empty(());
328 impl sealed::Sealed for Empty {}
329 impl State for Empty {
330 type Items = Unset;
331 }
332 pub struct SetItems<S: State = Empty>(PhantomData<fn() -> S>);
334 impl<S: State> sealed::Sealed for SetItems<S> {}
335 impl<S: State> State for SetItems<S> {
336 type Items = Set<members::items>;
337 }
338 #[allow(non_camel_case_types)]
340 pub mod members {
341 pub struct items(());
343 }
344}
345
346pub struct SendMessageBatchBuilder<'a, S: send_message_batch_state::State> {
348 _state: PhantomData<fn() -> S>,
349 _fields: (Option<Vec<send_message_batch::BatchItem<'a>>>,),
350 _lifetime: PhantomData<&'a ()>,
351}
352
353impl<'a> SendMessageBatch<'a> {
354 pub fn new() -> SendMessageBatchBuilder<'a, send_message_batch_state::Empty> {
356 SendMessageBatchBuilder::new()
357 }
358}
359
360impl<'a> SendMessageBatchBuilder<'a, send_message_batch_state::Empty> {
361 pub fn new() -> Self {
363 SendMessageBatchBuilder {
364 _state: PhantomData,
365 _fields: (None,),
366 _lifetime: PhantomData,
367 }
368 }
369}
370
371impl<'a, S> SendMessageBatchBuilder<'a, S>
372where
373 S: send_message_batch_state::State,
374 S::Items: send_message_batch_state::IsUnset,
375{
376 pub fn items(
378 mut self,
379 value: impl Into<Vec<send_message_batch::BatchItem<'a>>>,
380 ) -> SendMessageBatchBuilder<'a, send_message_batch_state::SetItems<S>> {
381 self._fields.0 = Option::Some(value.into());
382 SendMessageBatchBuilder {
383 _state: PhantomData,
384 _fields: self._fields,
385 _lifetime: PhantomData,
386 }
387 }
388}
389
390impl<'a, S> SendMessageBatchBuilder<'a, S>
391where
392 S: send_message_batch_state::State,
393 S::Items: send_message_batch_state::IsSet,
394{
395 pub fn build(self) -> SendMessageBatch<'a> {
397 SendMessageBatch {
398 items: self._fields.0.unwrap(),
399 extra_data: Default::default(),
400 }
401 }
402 pub fn build_with_data(
404 self,
405 extra_data: BTreeMap<
406 jacquard_common::deps::smol_str::SmolStr,
407 jacquard_common::types::value::Data<'a>,
408 >,
409 ) -> SendMessageBatch<'a> {
410 SendMessageBatch {
411 items: self._fields.0.unwrap(),
412 extra_data: Some(extra_data),
413 }
414 }
415}