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