jacquard_api/sh_weaver/edit/
diff.rs

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