jacquard_api/app_bsky/contact/
send_notification.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::types::string::Did;
14use jacquard_derive::{IntoStatic, lexicon};
15use serde::{Serialize, Deserialize};
16
17#[lexicon]
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct SendNotification<'a> {
21 #[serde(borrow)]
23 pub from: Did<'a>,
24 #[serde(borrow)]
26 pub to: Did<'a>,
27}
28
29
30#[lexicon]
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
32#[serde(rename_all = "camelCase")]
33pub struct SendNotificationOutput<'a> {}
34pub struct SendNotificationResponse;
36impl jacquard_common::xrpc::XrpcResp for SendNotificationResponse {
37 const NSID: &'static str = "app.bsky.contact.sendNotification";
38 const ENCODING: &'static str = "application/json";
39 type Output<'de> = SendNotificationOutput<'de>;
40 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
41}
42
43impl<'a> jacquard_common::xrpc::XrpcRequest for SendNotification<'a> {
44 const NSID: &'static str = "app.bsky.contact.sendNotification";
45 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
46 "application/json",
47 );
48 type Response = SendNotificationResponse;
49}
50
51pub struct SendNotificationRequest;
53impl jacquard_common::xrpc::XrpcEndpoint for SendNotificationRequest {
54 const PATH: &'static str = "/xrpc/app.bsky.contact.sendNotification";
55 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
56 "application/json",
57 );
58 type Request<'de> = SendNotification<'de>;
59 type Response = SendNotificationResponse;
60}
61
62pub mod send_notification_state {
63
64 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
65 #[allow(unused)]
66 use ::core::marker::PhantomData;
67 mod sealed {
68 pub trait Sealed {}
69 }
70 pub trait State: sealed::Sealed {
72 type From;
73 type To;
74 }
75 pub struct Empty(());
77 impl sealed::Sealed for Empty {}
78 impl State for Empty {
79 type From = Unset;
80 type To = Unset;
81 }
82 pub struct SetFrom<S: State = Empty>(PhantomData<fn() -> S>);
84 impl<S: State> sealed::Sealed for SetFrom<S> {}
85 impl<S: State> State for SetFrom<S> {
86 type From = Set<members::from>;
87 type To = S::To;
88 }
89 pub struct SetTo<S: State = Empty>(PhantomData<fn() -> S>);
91 impl<S: State> sealed::Sealed for SetTo<S> {}
92 impl<S: State> State for SetTo<S> {
93 type From = S::From;
94 type To = Set<members::to>;
95 }
96 #[allow(non_camel_case_types)]
98 pub mod members {
99 pub struct from(());
101 pub struct to(());
103 }
104}
105
106pub struct SendNotificationBuilder<'a, S: send_notification_state::State> {
108 _state: PhantomData<fn() -> S>,
109 _fields: (Option<Did<'a>>, Option<Did<'a>>),
110 _lifetime: PhantomData<&'a ()>,
111}
112
113impl<'a> SendNotification<'a> {
114 pub fn new() -> SendNotificationBuilder<'a, send_notification_state::Empty> {
116 SendNotificationBuilder::new()
117 }
118}
119
120impl<'a> SendNotificationBuilder<'a, send_notification_state::Empty> {
121 pub fn new() -> Self {
123 SendNotificationBuilder {
124 _state: PhantomData,
125 _fields: (None, None),
126 _lifetime: PhantomData,
127 }
128 }
129}
130
131impl<'a, S> SendNotificationBuilder<'a, S>
132where
133 S: send_notification_state::State,
134 S::From: send_notification_state::IsUnset,
135{
136 pub fn from(
138 mut self,
139 value: impl Into<Did<'a>>,
140 ) -> SendNotificationBuilder<'a, send_notification_state::SetFrom<S>> {
141 self._fields.0 = Option::Some(value.into());
142 SendNotificationBuilder {
143 _state: PhantomData,
144 _fields: self._fields,
145 _lifetime: PhantomData,
146 }
147 }
148}
149
150impl<'a, S> SendNotificationBuilder<'a, S>
151where
152 S: send_notification_state::State,
153 S::To: send_notification_state::IsUnset,
154{
155 pub fn to(
157 mut self,
158 value: impl Into<Did<'a>>,
159 ) -> SendNotificationBuilder<'a, send_notification_state::SetTo<S>> {
160 self._fields.1 = Option::Some(value.into());
161 SendNotificationBuilder {
162 _state: PhantomData,
163 _fields: self._fields,
164 _lifetime: PhantomData,
165 }
166 }
167}
168
169impl<'a, S> SendNotificationBuilder<'a, S>
170where
171 S: send_notification_state::State,
172 S::From: send_notification_state::IsSet,
173 S::To: send_notification_state::IsSet,
174{
175 pub fn build(self) -> SendNotification<'a> {
177 SendNotification {
178 from: self._fields.0.unwrap(),
179 to: self._fields.1.unwrap(),
180 extra_data: Default::default(),
181 }
182 }
183 pub fn build_with_data(
185 self,
186 extra_data: BTreeMap<
187 jacquard_common::deps::smol_str::SmolStr,
188 jacquard_common::types::value::Data<'a>,
189 >,
190 ) -> SendNotification<'a> {
191 SendNotification {
192 from: self._fields.0.unwrap(),
193 to: self._fields.1.unwrap(),
194 extra_data: Some(extra_data),
195 }
196 }
197}