A better Rust ATProto crate
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: dev.regnault.webfishing.savefile
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Record declaring a savefile of Webfishing.
9#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct Savefile<'a> {
21 #[serde(borrow)]
22 pub name: jacquard_common::CowStr<'a>,
23 #[serde(borrow)]
24 pub uri: jacquard_common::types::string::AtUri<'a>,
25}
26
27pub mod savefile_state {
28
29 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
30 #[allow(unused)]
31 use ::core::marker::PhantomData;
32 mod sealed {
33 pub trait Sealed {}
34 }
35 /// State trait tracking which required fields have been set
36 pub trait State: sealed::Sealed {
37 type Uri;
38 type Name;
39 }
40 /// Empty state - all required fields are unset
41 pub struct Empty(());
42 impl sealed::Sealed for Empty {}
43 impl State for Empty {
44 type Uri = Unset;
45 type Name = Unset;
46 }
47 ///State transition - sets the `uri` field to Set
48 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
49 impl<S: State> sealed::Sealed for SetUri<S> {}
50 impl<S: State> State for SetUri<S> {
51 type Uri = Set<members::uri>;
52 type Name = S::Name;
53 }
54 ///State transition - sets the `name` field to Set
55 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
56 impl<S: State> sealed::Sealed for SetName<S> {}
57 impl<S: State> State for SetName<S> {
58 type Uri = S::Uri;
59 type Name = Set<members::name>;
60 }
61 /// Marker types for field names
62 #[allow(non_camel_case_types)]
63 pub mod members {
64 ///Marker type for the `uri` field
65 pub struct uri(());
66 ///Marker type for the `name` field
67 pub struct name(());
68 }
69}
70
71/// Builder for constructing an instance of this type
72pub struct SavefileBuilder<'a, S: savefile_state::State> {
73 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
74 __unsafe_private_named: (
75 ::core::option::Option<jacquard_common::CowStr<'a>>,
76 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
77 ),
78 _phantom: ::core::marker::PhantomData<&'a ()>,
79}
80
81impl<'a> Savefile<'a> {
82 /// Create a new builder for this type
83 pub fn new() -> SavefileBuilder<'a, savefile_state::Empty> {
84 SavefileBuilder::new()
85 }
86}
87
88impl<'a> SavefileBuilder<'a, savefile_state::Empty> {
89 /// Create a new builder with all fields unset
90 pub fn new() -> Self {
91 SavefileBuilder {
92 _phantom_state: ::core::marker::PhantomData,
93 __unsafe_private_named: (None, None),
94 _phantom: ::core::marker::PhantomData,
95 }
96 }
97}
98
99impl<'a, S> SavefileBuilder<'a, S>
100where
101 S: savefile_state::State,
102 S::Name: savefile_state::IsUnset,
103{
104 /// Set the `name` field (required)
105 pub fn name(
106 mut self,
107 value: impl Into<jacquard_common::CowStr<'a>>,
108 ) -> SavefileBuilder<'a, savefile_state::SetName<S>> {
109 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
110 SavefileBuilder {
111 _phantom_state: ::core::marker::PhantomData,
112 __unsafe_private_named: self.__unsafe_private_named,
113 _phantom: ::core::marker::PhantomData,
114 }
115 }
116}
117
118impl<'a, S> SavefileBuilder<'a, S>
119where
120 S: savefile_state::State,
121 S::Uri: savefile_state::IsUnset,
122{
123 /// Set the `uri` field (required)
124 pub fn uri(
125 mut self,
126 value: impl Into<jacquard_common::types::string::AtUri<'a>>,
127 ) -> SavefileBuilder<'a, savefile_state::SetUri<S>> {
128 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
129 SavefileBuilder {
130 _phantom_state: ::core::marker::PhantomData,
131 __unsafe_private_named: self.__unsafe_private_named,
132 _phantom: ::core::marker::PhantomData,
133 }
134 }
135}
136
137impl<'a, S> SavefileBuilder<'a, S>
138where
139 S: savefile_state::State,
140 S::Uri: savefile_state::IsSet,
141 S::Name: savefile_state::IsSet,
142{
143 /// Build the final struct
144 pub fn build(self) -> Savefile<'a> {
145 Savefile {
146 name: self.__unsafe_private_named.0.unwrap(),
147 uri: self.__unsafe_private_named.1.unwrap(),
148 extra_data: Default::default(),
149 }
150 }
151 /// Build the final struct with custom extra_data
152 pub fn build_with_data(
153 self,
154 extra_data: std::collections::BTreeMap<
155 jacquard_common::smol_str::SmolStr,
156 jacquard_common::types::value::Data<'a>,
157 >,
158 ) -> Savefile<'a> {
159 Savefile {
160 name: self.__unsafe_private_named.0.unwrap(),
161 uri: self.__unsafe_private_named.1.unwrap(),
162 extra_data: Some(extra_data),
163 }
164 }
165}
166
167impl<'a> Savefile<'a> {
168 pub fn uri(
169 uri: impl Into<jacquard_common::CowStr<'a>>,
170 ) -> Result<
171 jacquard_common::types::uri::RecordUri<'a, SavefileRecord>,
172 jacquard_common::types::uri::UriError,
173 > {
174 jacquard_common::types::uri::RecordUri::try_from_uri(
175 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
176 )
177 }
178}
179
180/// Typed wrapper for GetRecord response with this collection's record type.
181#[derive(
182 serde::Serialize,
183 serde::Deserialize,
184 Debug,
185 Clone,
186 PartialEq,
187 Eq,
188 jacquard_derive::IntoStatic
189)]
190#[serde(rename_all = "camelCase")]
191pub struct SavefileGetRecordOutput<'a> {
192 #[serde(skip_serializing_if = "std::option::Option::is_none")]
193 #[serde(borrow)]
194 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
195 #[serde(borrow)]
196 pub uri: jacquard_common::types::string::AtUri<'a>,
197 #[serde(borrow)]
198 pub value: Savefile<'a>,
199}
200
201impl From<SavefileGetRecordOutput<'_>> for Savefile<'_> {
202 fn from(output: SavefileGetRecordOutput<'_>) -> Self {
203 use jacquard_common::IntoStatic;
204 output.value.into_static()
205 }
206}
207
208impl jacquard_common::types::collection::Collection for Savefile<'_> {
209 const NSID: &'static str = "dev.regnault.webfishing.savefile";
210 type Record = SavefileRecord;
211}
212
213/// Marker type for deserializing records from this collection.
214#[derive(Debug, serde::Serialize, serde::Deserialize)]
215pub struct SavefileRecord;
216impl jacquard_common::xrpc::XrpcResp for SavefileRecord {
217 const NSID: &'static str = "dev.regnault.webfishing.savefile";
218 const ENCODING: &'static str = "application/json";
219 type Output<'de> = SavefileGetRecordOutput<'de>;
220 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
221}
222
223impl jacquard_common::types::collection::Collection for SavefileRecord {
224 const NSID: &'static str = "dev.regnault.webfishing.savefile";
225 type Record = SavefileRecord;
226}
227
228impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Savefile<'a> {
229 fn nsid() -> &'static str {
230 "dev.regnault.webfishing.savefile"
231 }
232 fn def_name() -> &'static str {
233 "main"
234 }
235 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
236 lexicon_doc_dev_regnault_webfishing_savefile()
237 }
238 fn validate(
239 &self,
240 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
241 Ok(())
242 }
243}
244
245fn lexicon_doc_dev_regnault_webfishing_savefile() -> ::jacquard_lexicon::lexicon::LexiconDoc<
246 'static,
247> {
248 ::jacquard_lexicon::lexicon::LexiconDoc {
249 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
250 id: ::jacquard_common::CowStr::new_static("dev.regnault.webfishing.savefile"),
251 revision: None,
252 description: None,
253 defs: {
254 let mut map = ::alloc::collections::BTreeMap::new();
255 map.insert(
256 ::jacquard_common::smol_str::SmolStr::new_static("main"),
257 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
258 description: Some(
259 ::jacquard_common::CowStr::new_static(
260 "Record declaring a savefile of Webfishing.",
261 ),
262 ),
263 key: Some(::jacquard_common::CowStr::new_static("tid")),
264 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
265 description: None,
266 required: Some(
267 vec![
268 ::jacquard_common::smol_str::SmolStr::new_static("name"),
269 ::jacquard_common::smol_str::SmolStr::new_static("uri")
270 ],
271 ),
272 nullable: None,
273 properties: {
274 #[allow(unused_mut)]
275 let mut map = ::alloc::collections::BTreeMap::new();
276 map.insert(
277 ::jacquard_common::smol_str::SmolStr::new_static("name"),
278 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
279 description: None,
280 format: None,
281 default: None,
282 min_length: None,
283 max_length: None,
284 min_graphemes: None,
285 max_graphemes: None,
286 r#enum: None,
287 r#const: None,
288 known_values: None,
289 }),
290 );
291 map.insert(
292 ::jacquard_common::smol_str::SmolStr::new_static("uri"),
293 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
294 description: None,
295 format: Some(
296 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
297 ),
298 default: None,
299 min_length: None,
300 max_length: None,
301 min_graphemes: None,
302 max_graphemes: None,
303 r#enum: None,
304 r#const: None,
305 known_values: None,
306 }),
307 );
308 map
309 },
310 }),
311 }),
312 );
313 map
314 },
315 }
316}