Skip to main content

jacquard_api/chat_bsky/convo/
send_message.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: chat.bsky.convo.sendMessage
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_derive::{IntoStatic, lexicon};
15use serde::{Serialize, Deserialize};
16use crate::chat_bsky::convo::MessageInput;
17use crate::chat_bsky::convo::MessageView;
18
19#[lexicon]
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase")]
22pub struct SendMessage<'a> {
23    #[serde(borrow)]
24    pub convo_id: CowStr<'a>,
25    #[serde(borrow)]
26    pub message: MessageInput<'a>,
27}
28
29
30#[lexicon]
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
32#[serde(rename_all = "camelCase")]
33pub struct SendMessageOutput<'a> {
34    #[serde(flatten)]
35    #[serde(borrow)]
36    pub value: MessageView<'a>,
37}
38
39/// Response type for chat.bsky.convo.sendMessage
40pub struct SendMessageResponse;
41impl jacquard_common::xrpc::XrpcResp for SendMessageResponse {
42    const NSID: &'static str = "chat.bsky.convo.sendMessage";
43    const ENCODING: &'static str = "application/json";
44    type Output<'de> = SendMessageOutput<'de>;
45    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
46}
47
48impl<'a> jacquard_common::xrpc::XrpcRequest for SendMessage<'a> {
49    const NSID: &'static str = "chat.bsky.convo.sendMessage";
50    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
51        "application/json",
52    );
53    type Response = SendMessageResponse;
54}
55
56/// Endpoint type for chat.bsky.convo.sendMessage
57pub struct SendMessageRequest;
58impl jacquard_common::xrpc::XrpcEndpoint for SendMessageRequest {
59    const PATH: &'static str = "/xrpc/chat.bsky.convo.sendMessage";
60    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
61        "application/json",
62    );
63    type Request<'de> = SendMessage<'de>;
64    type Response = SendMessageResponse;
65}
66
67pub mod send_message_state {
68
69    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
70    #[allow(unused)]
71    use ::core::marker::PhantomData;
72    mod sealed {
73        pub trait Sealed {}
74    }
75    /// State trait tracking which required fields have been set
76    pub trait State: sealed::Sealed {
77        type ConvoId;
78        type Message;
79    }
80    /// Empty state - all required fields are unset
81    pub struct Empty(());
82    impl sealed::Sealed for Empty {}
83    impl State for Empty {
84        type ConvoId = Unset;
85        type Message = Unset;
86    }
87    ///State transition - sets the `convo_id` field to Set
88    pub struct SetConvoId<S: State = Empty>(PhantomData<fn() -> S>);
89    impl<S: State> sealed::Sealed for SetConvoId<S> {}
90    impl<S: State> State for SetConvoId<S> {
91        type ConvoId = Set<members::convo_id>;
92        type Message = S::Message;
93    }
94    ///State transition - sets the `message` field to Set
95    pub struct SetMessage<S: State = Empty>(PhantomData<fn() -> S>);
96    impl<S: State> sealed::Sealed for SetMessage<S> {}
97    impl<S: State> State for SetMessage<S> {
98        type ConvoId = S::ConvoId;
99        type Message = Set<members::message>;
100    }
101    /// Marker types for field names
102    #[allow(non_camel_case_types)]
103    pub mod members {
104        ///Marker type for the `convo_id` field
105        pub struct convo_id(());
106        ///Marker type for the `message` field
107        pub struct message(());
108    }
109}
110
111/// Builder for constructing an instance of this type
112pub struct SendMessageBuilder<'a, S: send_message_state::State> {
113    _state: PhantomData<fn() -> S>,
114    _fields: (Option<CowStr<'a>>, Option<MessageInput<'a>>),
115    _lifetime: PhantomData<&'a ()>,
116}
117
118impl<'a> SendMessage<'a> {
119    /// Create a new builder for this type
120    pub fn new() -> SendMessageBuilder<'a, send_message_state::Empty> {
121        SendMessageBuilder::new()
122    }
123}
124
125impl<'a> SendMessageBuilder<'a, send_message_state::Empty> {
126    /// Create a new builder with all fields unset
127    pub fn new() -> Self {
128        SendMessageBuilder {
129            _state: PhantomData,
130            _fields: (None, None),
131            _lifetime: PhantomData,
132        }
133    }
134}
135
136impl<'a, S> SendMessageBuilder<'a, S>
137where
138    S: send_message_state::State,
139    S::ConvoId: send_message_state::IsUnset,
140{
141    /// Set the `convoId` field (required)
142    pub fn convo_id(
143        mut self,
144        value: impl Into<CowStr<'a>>,
145    ) -> SendMessageBuilder<'a, send_message_state::SetConvoId<S>> {
146        self._fields.0 = Option::Some(value.into());
147        SendMessageBuilder {
148            _state: PhantomData,
149            _fields: self._fields,
150            _lifetime: PhantomData,
151        }
152    }
153}
154
155impl<'a, S> SendMessageBuilder<'a, S>
156where
157    S: send_message_state::State,
158    S::Message: send_message_state::IsUnset,
159{
160    /// Set the `message` field (required)
161    pub fn message(
162        mut self,
163        value: impl Into<MessageInput<'a>>,
164    ) -> SendMessageBuilder<'a, send_message_state::SetMessage<S>> {
165        self._fields.1 = Option::Some(value.into());
166        SendMessageBuilder {
167            _state: PhantomData,
168            _fields: self._fields,
169            _lifetime: PhantomData,
170        }
171    }
172}
173
174impl<'a, S> SendMessageBuilder<'a, S>
175where
176    S: send_message_state::State,
177    S::ConvoId: send_message_state::IsSet,
178    S::Message: send_message_state::IsSet,
179{
180    /// Build the final struct
181    pub fn build(self) -> SendMessage<'a> {
182        SendMessage {
183            convo_id: self._fields.0.unwrap(),
184            message: self._fields.1.unwrap(),
185            extra_data: Default::default(),
186        }
187    }
188    /// Build the final struct with custom extra_data
189    pub fn build_with_data(
190        self,
191        extra_data: BTreeMap<
192            jacquard_common::deps::smol_str::SmolStr,
193            jacquard_common::types::value::Data<'a>,
194        >,
195    ) -> SendMessage<'a> {
196        SendMessage {
197            convo_id: self._fields.0.unwrap(),
198            message: self._fields.1.unwrap(),
199            extra_data: Some(extra_data),
200        }
201    }
202}