jacquard_api/com_atproto/admin/
send_email.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::Did;
15use jacquard_derive::{IntoStatic, lexicon};
16use serde::{Serialize, Deserialize};
17
18#[lexicon]
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct SendEmail<'a> {
22 #[serde(skip_serializing_if = "Option::is_none")]
24 #[serde(borrow)]
25 pub comment: Option<CowStr<'a>>,
26 #[serde(borrow)]
27 pub content: CowStr<'a>,
28 #[serde(borrow)]
29 pub recipient_did: Did<'a>,
30 #[serde(borrow)]
31 pub sender_did: Did<'a>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 #[serde(borrow)]
34 pub subject: Option<CowStr<'a>>,
35}
36
37
38#[lexicon]
39#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
40#[serde(rename_all = "camelCase")]
41pub struct SendEmailOutput<'a> {
42 pub sent: bool,
43}
44
45pub struct SendEmailResponse;
47impl jacquard_common::xrpc::XrpcResp for SendEmailResponse {
48 const NSID: &'static str = "com.atproto.admin.sendEmail";
49 const ENCODING: &'static str = "application/json";
50 type Output<'de> = SendEmailOutput<'de>;
51 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
52}
53
54impl<'a> jacquard_common::xrpc::XrpcRequest for SendEmail<'a> {
55 const NSID: &'static str = "com.atproto.admin.sendEmail";
56 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
57 "application/json",
58 );
59 type Response = SendEmailResponse;
60}
61
62pub struct SendEmailRequest;
64impl jacquard_common::xrpc::XrpcEndpoint for SendEmailRequest {
65 const PATH: &'static str = "/xrpc/com.atproto.admin.sendEmail";
66 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
67 "application/json",
68 );
69 type Request<'de> = SendEmail<'de>;
70 type Response = SendEmailResponse;
71}
72
73pub mod send_email_state {
74
75 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
76 #[allow(unused)]
77 use ::core::marker::PhantomData;
78 mod sealed {
79 pub trait Sealed {}
80 }
81 pub trait State: sealed::Sealed {
83 type Content;
84 type SenderDid;
85 type RecipientDid;
86 }
87 pub struct Empty(());
89 impl sealed::Sealed for Empty {}
90 impl State for Empty {
91 type Content = Unset;
92 type SenderDid = Unset;
93 type RecipientDid = Unset;
94 }
95 pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
97 impl<S: State> sealed::Sealed for SetContent<S> {}
98 impl<S: State> State for SetContent<S> {
99 type Content = Set<members::content>;
100 type SenderDid = S::SenderDid;
101 type RecipientDid = S::RecipientDid;
102 }
103 pub struct SetSenderDid<S: State = Empty>(PhantomData<fn() -> S>);
105 impl<S: State> sealed::Sealed for SetSenderDid<S> {}
106 impl<S: State> State for SetSenderDid<S> {
107 type Content = S::Content;
108 type SenderDid = Set<members::sender_did>;
109 type RecipientDid = S::RecipientDid;
110 }
111 pub struct SetRecipientDid<S: State = Empty>(PhantomData<fn() -> S>);
113 impl<S: State> sealed::Sealed for SetRecipientDid<S> {}
114 impl<S: State> State for SetRecipientDid<S> {
115 type Content = S::Content;
116 type SenderDid = S::SenderDid;
117 type RecipientDid = Set<members::recipient_did>;
118 }
119 #[allow(non_camel_case_types)]
121 pub mod members {
122 pub struct content(());
124 pub struct sender_did(());
126 pub struct recipient_did(());
128 }
129}
130
131pub struct SendEmailBuilder<'a, S: send_email_state::State> {
133 _state: PhantomData<fn() -> S>,
134 _fields: (
135 Option<CowStr<'a>>,
136 Option<CowStr<'a>>,
137 Option<Did<'a>>,
138 Option<Did<'a>>,
139 Option<CowStr<'a>>,
140 ),
141 _lifetime: PhantomData<&'a ()>,
142}
143
144impl<'a> SendEmail<'a> {
145 pub fn new() -> SendEmailBuilder<'a, send_email_state::Empty> {
147 SendEmailBuilder::new()
148 }
149}
150
151impl<'a> SendEmailBuilder<'a, send_email_state::Empty> {
152 pub fn new() -> Self {
154 SendEmailBuilder {
155 _state: PhantomData,
156 _fields: (None, None, None, None, None),
157 _lifetime: PhantomData,
158 }
159 }
160}
161
162impl<'a, S: send_email_state::State> SendEmailBuilder<'a, S> {
163 pub fn comment(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
165 self._fields.0 = value.into();
166 self
167 }
168 pub fn maybe_comment(mut self, value: Option<CowStr<'a>>) -> Self {
170 self._fields.0 = value;
171 self
172 }
173}
174
175impl<'a, S> SendEmailBuilder<'a, S>
176where
177 S: send_email_state::State,
178 S::Content: send_email_state::IsUnset,
179{
180 pub fn content(
182 mut self,
183 value: impl Into<CowStr<'a>>,
184 ) -> SendEmailBuilder<'a, send_email_state::SetContent<S>> {
185 self._fields.1 = Option::Some(value.into());
186 SendEmailBuilder {
187 _state: PhantomData,
188 _fields: self._fields,
189 _lifetime: PhantomData,
190 }
191 }
192}
193
194impl<'a, S> SendEmailBuilder<'a, S>
195where
196 S: send_email_state::State,
197 S::RecipientDid: send_email_state::IsUnset,
198{
199 pub fn recipient_did(
201 mut self,
202 value: impl Into<Did<'a>>,
203 ) -> SendEmailBuilder<'a, send_email_state::SetRecipientDid<S>> {
204 self._fields.2 = Option::Some(value.into());
205 SendEmailBuilder {
206 _state: PhantomData,
207 _fields: self._fields,
208 _lifetime: PhantomData,
209 }
210 }
211}
212
213impl<'a, S> SendEmailBuilder<'a, S>
214where
215 S: send_email_state::State,
216 S::SenderDid: send_email_state::IsUnset,
217{
218 pub fn sender_did(
220 mut self,
221 value: impl Into<Did<'a>>,
222 ) -> SendEmailBuilder<'a, send_email_state::SetSenderDid<S>> {
223 self._fields.3 = Option::Some(value.into());
224 SendEmailBuilder {
225 _state: PhantomData,
226 _fields: self._fields,
227 _lifetime: PhantomData,
228 }
229 }
230}
231
232impl<'a, S: send_email_state::State> SendEmailBuilder<'a, S> {
233 pub fn subject(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
235 self._fields.4 = value.into();
236 self
237 }
238 pub fn maybe_subject(mut self, value: Option<CowStr<'a>>) -> Self {
240 self._fields.4 = value;
241 self
242 }
243}
244
245impl<'a, S> SendEmailBuilder<'a, S>
246where
247 S: send_email_state::State,
248 S::Content: send_email_state::IsSet,
249 S::SenderDid: send_email_state::IsSet,
250 S::RecipientDid: send_email_state::IsSet,
251{
252 pub fn build(self) -> SendEmail<'a> {
254 SendEmail {
255 comment: self._fields.0,
256 content: self._fields.1.unwrap(),
257 recipient_did: self._fields.2.unwrap(),
258 sender_did: self._fields.3.unwrap(),
259 subject: self._fields.4,
260 extra_data: Default::default(),
261 }
262 }
263 pub fn build_with_data(
265 self,
266 extra_data: BTreeMap<
267 jacquard_common::deps::smol_str::SmolStr,
268 jacquard_common::types::value::Data<'a>,
269 >,
270 ) -> SendEmail<'a> {
271 SendEmail {
272 comment: self._fields.0,
273 content: self._fields.1.unwrap(),
274 recipient_did: self._fields.2.unwrap(),
275 sender_did: self._fields.3.unwrap(),
276 subject: self._fields.4,
277 extra_data: Some(extra_data),
278 }
279 }
280}