Skip to main content

jacquard_api/sh_weaver/edit/
cursor.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.edit.cursor
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::collection::{Collection, RecordError};
18use jacquard_common::types::string::{AtUri, Cid};
19use jacquard_common::types::uri::{RecordUri, UriError};
20use jacquard_common::xrpc::XrpcResp;
21use jacquard_derive::{IntoStatic, lexicon, open_union};
22use jacquard_lexicon::lexicon::LexiconDoc;
23use jacquard_lexicon::schema::LexiconSchema;
24
25#[allow(unused_imports)]
26use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
27use serde::{Serialize, Deserialize};
28use crate::sh_weaver::edit::cursor;
29
30#[lexicon]
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
32#[serde(rename_all = "camelCase")]
33pub struct ContainerId<'a> {
34    #[serde(borrow)]
35    pub value: ContainerIdValue<'a>,
36}
37
38
39#[open_union]
40#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
41#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
42pub enum ContainerIdValue<'a> {
43    #[serde(rename = "sh.weaver.edit.cursor#normalContainerId")]
44    NormalContainerId(Box<cursor::NormalContainerId<'a>>),
45    #[serde(rename = "sh.weaver.edit.cursor#rootContainerId")]
46    RootContainerId(Box<cursor::RootContainerId<'a>>),
47}
48
49
50#[lexicon]
51#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
52#[serde(rename_all = "camelCase")]
53pub struct CursorSide<'a> {
54    ///The side of an item the cursor is on (left = -1, right = 1, middle = 0)
55    pub value: i64,
56}
57
58
59#[lexicon]
60#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
61#[serde(rename_all = "camelCase")]
62pub struct Id<'a> {
63    pub counter: i64,
64    pub peer: i64,
65}
66
67/// An edit record for a notebook.
68
69#[lexicon]
70#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
71#[serde(rename_all = "camelCase", rename = "sh.weaver.edit.cursor", tag = "$type")]
72pub struct Cursor<'a> {
73    #[serde(borrow)]
74    pub container: cursor::ContainerId<'a>,
75    #[serde(borrow)]
76    pub id: cursor::Id<'a>,
77    #[serde(skip_serializing_if = "Option::is_none")]
78    #[serde(borrow)]
79    pub side: Option<cursor::CursorSide<'a>>,
80}
81
82/// Typed wrapper for GetRecord response with this collection's record type.
83
84#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
85#[serde(rename_all = "camelCase")]
86pub struct CursorGetRecordOutput<'a> {
87    #[serde(skip_serializing_if = "Option::is_none")]
88    #[serde(borrow)]
89    pub cid: Option<Cid<'a>>,
90    #[serde(borrow)]
91    pub uri: AtUri<'a>,
92    #[serde(borrow)]
93    pub value: Cursor<'a>,
94}
95
96
97#[lexicon]
98#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
99#[serde(rename_all = "camelCase")]
100pub struct NormalContainerId<'a> {
101    #[serde(borrow)]
102    pub container_type: CowStr<'a>,
103    pub counter: i64,
104    pub peer: i64,
105}
106
107
108#[lexicon]
109#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
110#[serde(rename_all = "camelCase")]
111pub struct RootContainerId<'a> {
112    #[serde(borrow)]
113    pub container_type: CowStr<'a>,
114    #[serde(borrow)]
115    pub name: CowStr<'a>,
116}
117
118impl<'a> Cursor<'a> {
119    pub fn uri(
120        uri: impl Into<CowStr<'a>>,
121    ) -> Result<RecordUri<'a, CursorRecord>, UriError> {
122        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
123    }
124}
125
126impl<'a> LexiconSchema for ContainerId<'a> {
127    fn nsid() -> &'static str {
128        "sh.weaver.edit.cursor"
129    }
130    fn def_name() -> &'static str {
131        "containerId"
132    }
133    fn lexicon_doc() -> LexiconDoc<'static> {
134        lexicon_doc_sh_weaver_edit_cursor()
135    }
136    fn validate(&self) -> Result<(), ConstraintError> {
137        Ok(())
138    }
139}
140
141impl<'a> LexiconSchema for CursorSide<'a> {
142    fn nsid() -> &'static str {
143        "sh.weaver.edit.cursor"
144    }
145    fn def_name() -> &'static str {
146        "cursorSide"
147    }
148    fn lexicon_doc() -> LexiconDoc<'static> {
149        lexicon_doc_sh_weaver_edit_cursor()
150    }
151    fn validate(&self) -> Result<(), ConstraintError> {
152        Ok(())
153    }
154}
155
156impl<'a> LexiconSchema for Id<'a> {
157    fn nsid() -> &'static str {
158        "sh.weaver.edit.cursor"
159    }
160    fn def_name() -> &'static str {
161        "id"
162    }
163    fn lexicon_doc() -> LexiconDoc<'static> {
164        lexicon_doc_sh_weaver_edit_cursor()
165    }
166    fn validate(&self) -> Result<(), ConstraintError> {
167        Ok(())
168    }
169}
170
171/// Marker type for deserializing records from this collection.
172
173#[derive(Debug, Serialize, Deserialize)]
174pub struct CursorRecord;
175impl XrpcResp for CursorRecord {
176    const NSID: &'static str = "sh.weaver.edit.cursor";
177    const ENCODING: &'static str = "application/json";
178    type Output<'de> = CursorGetRecordOutput<'de>;
179    type Err<'de> = RecordError<'de>;
180}
181
182impl From<CursorGetRecordOutput<'_>> for Cursor<'_> {
183    fn from(output: CursorGetRecordOutput<'_>) -> Self {
184        use jacquard_common::IntoStatic;
185        output.value.into_static()
186    }
187}
188
189impl Collection for Cursor<'_> {
190    const NSID: &'static str = "sh.weaver.edit.cursor";
191    type Record = CursorRecord;
192}
193
194impl Collection for CursorRecord {
195    const NSID: &'static str = "sh.weaver.edit.cursor";
196    type Record = CursorRecord;
197}
198
199impl<'a> LexiconSchema for Cursor<'a> {
200    fn nsid() -> &'static str {
201        "sh.weaver.edit.cursor"
202    }
203    fn def_name() -> &'static str {
204        "main"
205    }
206    fn lexicon_doc() -> LexiconDoc<'static> {
207        lexicon_doc_sh_weaver_edit_cursor()
208    }
209    fn validate(&self) -> Result<(), ConstraintError> {
210        Ok(())
211    }
212}
213
214impl<'a> LexiconSchema for NormalContainerId<'a> {
215    fn nsid() -> &'static str {
216        "sh.weaver.edit.cursor"
217    }
218    fn def_name() -> &'static str {
219        "normalContainerId"
220    }
221    fn lexicon_doc() -> LexiconDoc<'static> {
222        lexicon_doc_sh_weaver_edit_cursor()
223    }
224    fn validate(&self) -> Result<(), ConstraintError> {
225        Ok(())
226    }
227}
228
229impl<'a> LexiconSchema for RootContainerId<'a> {
230    fn nsid() -> &'static str {
231        "sh.weaver.edit.cursor"
232    }
233    fn def_name() -> &'static str {
234        "rootContainerId"
235    }
236    fn lexicon_doc() -> LexiconDoc<'static> {
237        lexicon_doc_sh_weaver_edit_cursor()
238    }
239    fn validate(&self) -> Result<(), ConstraintError> {
240        Ok(())
241    }
242}
243
244pub mod container_id_state {
245
246    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
247    #[allow(unused)]
248    use ::core::marker::PhantomData;
249    mod sealed {
250        pub trait Sealed {}
251    }
252    /// State trait tracking which required fields have been set
253    pub trait State: sealed::Sealed {
254        type Value;
255    }
256    /// Empty state - all required fields are unset
257    pub struct Empty(());
258    impl sealed::Sealed for Empty {}
259    impl State for Empty {
260        type Value = Unset;
261    }
262    ///State transition - sets the `value` field to Set
263    pub struct SetValue<S: State = Empty>(PhantomData<fn() -> S>);
264    impl<S: State> sealed::Sealed for SetValue<S> {}
265    impl<S: State> State for SetValue<S> {
266        type Value = Set<members::value>;
267    }
268    /// Marker types for field names
269    #[allow(non_camel_case_types)]
270    pub mod members {
271        ///Marker type for the `value` field
272        pub struct value(());
273    }
274}
275
276/// Builder for constructing an instance of this type
277pub struct ContainerIdBuilder<'a, S: container_id_state::State> {
278    _state: PhantomData<fn() -> S>,
279    _fields: (Option<ContainerIdValue<'a>>,),
280    _lifetime: PhantomData<&'a ()>,
281}
282
283impl<'a> ContainerId<'a> {
284    /// Create a new builder for this type
285    pub fn new() -> ContainerIdBuilder<'a, container_id_state::Empty> {
286        ContainerIdBuilder::new()
287    }
288}
289
290impl<'a> ContainerIdBuilder<'a, container_id_state::Empty> {
291    /// Create a new builder with all fields unset
292    pub fn new() -> Self {
293        ContainerIdBuilder {
294            _state: PhantomData,
295            _fields: (None,),
296            _lifetime: PhantomData,
297        }
298    }
299}
300
301impl<'a, S> ContainerIdBuilder<'a, S>
302where
303    S: container_id_state::State,
304    S::Value: container_id_state::IsUnset,
305{
306    /// Set the `value` field (required)
307    pub fn value(
308        mut self,
309        value: impl Into<ContainerIdValue<'a>>,
310    ) -> ContainerIdBuilder<'a, container_id_state::SetValue<S>> {
311        self._fields.0 = Option::Some(value.into());
312        ContainerIdBuilder {
313            _state: PhantomData,
314            _fields: self._fields,
315            _lifetime: PhantomData,
316        }
317    }
318}
319
320impl<'a, S> ContainerIdBuilder<'a, S>
321where
322    S: container_id_state::State,
323    S::Value: container_id_state::IsSet,
324{
325    /// Build the final struct
326    pub fn build(self) -> ContainerId<'a> {
327        ContainerId {
328            value: self._fields.0.unwrap(),
329            extra_data: Default::default(),
330        }
331    }
332    /// Build the final struct with custom extra_data
333    pub fn build_with_data(
334        self,
335        extra_data: BTreeMap<
336            jacquard_common::deps::smol_str::SmolStr,
337            jacquard_common::types::value::Data<'a>,
338        >,
339    ) -> ContainerId<'a> {
340        ContainerId {
341            value: self._fields.0.unwrap(),
342            extra_data: Some(extra_data),
343        }
344    }
345}
346
347fn lexicon_doc_sh_weaver_edit_cursor() -> LexiconDoc<'static> {
348    #[allow(unused_imports)]
349    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
350    use jacquard_lexicon::lexicon::*;
351    use alloc::collections::BTreeMap;
352    LexiconDoc {
353        lexicon: Lexicon::Lexicon1,
354        id: CowStr::new_static("sh.weaver.edit.cursor"),
355        defs: {
356            let mut map = BTreeMap::new();
357            map.insert(
358                SmolStr::new_static("containerId"),
359                LexUserType::Object(LexObject {
360                    required: Some(vec![SmolStr::new_static("value")]),
361                    properties: {
362                        #[allow(unused_mut)]
363                        let mut map = BTreeMap::new();
364                        map.insert(
365                            SmolStr::new_static("value"),
366                            LexObjectProperty::Union(LexRefUnion {
367                                refs: vec![
368                                    CowStr::new_static("#normalContainerId"),
369                                    CowStr::new_static("#rootContainerId")
370                                ],
371                                ..Default::default()
372                            }),
373                        );
374                        map
375                    },
376                    ..Default::default()
377                }),
378            );
379            map.insert(
380                SmolStr::new_static("cursorSide"),
381                LexUserType::Object(LexObject {
382                    required: Some(vec![SmolStr::new_static("value")]),
383                    properties: {
384                        #[allow(unused_mut)]
385                        let mut map = BTreeMap::new();
386                        map.insert(
387                            SmolStr::new_static("value"),
388                            LexObjectProperty::Integer(LexInteger {
389                                ..Default::default()
390                            }),
391                        );
392                        map
393                    },
394                    ..Default::default()
395                }),
396            );
397            map.insert(
398                SmolStr::new_static("id"),
399                LexUserType::Object(LexObject {
400                    required: Some(
401                        vec![SmolStr::new_static("peer"), SmolStr::new_static("counter")],
402                    ),
403                    properties: {
404                        #[allow(unused_mut)]
405                        let mut map = BTreeMap::new();
406                        map.insert(
407                            SmolStr::new_static("counter"),
408                            LexObjectProperty::Integer(LexInteger {
409                                ..Default::default()
410                            }),
411                        );
412                        map.insert(
413                            SmolStr::new_static("peer"),
414                            LexObjectProperty::Integer(LexInteger {
415                                ..Default::default()
416                            }),
417                        );
418                        map
419                    },
420                    ..Default::default()
421                }),
422            );
423            map.insert(
424                SmolStr::new_static("main"),
425                LexUserType::Record(LexRecord {
426                    description: Some(
427                        CowStr::new_static("An edit record for a notebook."),
428                    ),
429                    key: Some(CowStr::new_static("tid")),
430                    record: LexRecordRecord::Object(LexObject {
431                        required: Some(
432                            vec![
433                                SmolStr::new_static("container"), SmolStr::new_static("id")
434                            ],
435                        ),
436                        properties: {
437                            #[allow(unused_mut)]
438                            let mut map = BTreeMap::new();
439                            map.insert(
440                                SmolStr::new_static("container"),
441                                LexObjectProperty::Ref(LexRef {
442                                    r#ref: CowStr::new_static("#containerId"),
443                                    ..Default::default()
444                                }),
445                            );
446                            map.insert(
447                                SmolStr::new_static("id"),
448                                LexObjectProperty::Ref(LexRef {
449                                    r#ref: CowStr::new_static("#id"),
450                                    ..Default::default()
451                                }),
452                            );
453                            map.insert(
454                                SmolStr::new_static("side"),
455                                LexObjectProperty::Ref(LexRef {
456                                    r#ref: CowStr::new_static("#cursorSide"),
457                                    ..Default::default()
458                                }),
459                            );
460                            map
461                        },
462                        ..Default::default()
463                    }),
464                    ..Default::default()
465                }),
466            );
467            map.insert(
468                SmolStr::new_static("normalContainerId"),
469                LexUserType::Object(LexObject {
470                    required: Some(
471                        vec![
472                            SmolStr::new_static("peer"), SmolStr::new_static("counter"),
473                            SmolStr::new_static("container_type")
474                        ],
475                    ),
476                    properties: {
477                        #[allow(unused_mut)]
478                        let mut map = BTreeMap::new();
479                        map.insert(
480                            SmolStr::new_static("container_type"),
481                            LexObjectProperty::String(LexString { ..Default::default() }),
482                        );
483                        map.insert(
484                            SmolStr::new_static("counter"),
485                            LexObjectProperty::Integer(LexInteger {
486                                ..Default::default()
487                            }),
488                        );
489                        map.insert(
490                            SmolStr::new_static("peer"),
491                            LexObjectProperty::Integer(LexInteger {
492                                ..Default::default()
493                            }),
494                        );
495                        map
496                    },
497                    ..Default::default()
498                }),
499            );
500            map.insert(
501                SmolStr::new_static("rootContainerId"),
502                LexUserType::Object(LexObject {
503                    required: Some(
504                        vec![
505                            SmolStr::new_static("name"),
506                            SmolStr::new_static("container_type")
507                        ],
508                    ),
509                    properties: {
510                        #[allow(unused_mut)]
511                        let mut map = BTreeMap::new();
512                        map.insert(
513                            SmolStr::new_static("container_type"),
514                            LexObjectProperty::String(LexString { ..Default::default() }),
515                        );
516                        map.insert(
517                            SmolStr::new_static("name"),
518                            LexObjectProperty::String(LexString { ..Default::default() }),
519                        );
520                        map
521                    },
522                    ..Default::default()
523                }),
524            );
525            map
526        },
527        ..Default::default()
528    }
529}
530
531pub mod cursor_side_state {
532
533    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
534    #[allow(unused)]
535    use ::core::marker::PhantomData;
536    mod sealed {
537        pub trait Sealed {}
538    }
539    /// State trait tracking which required fields have been set
540    pub trait State: sealed::Sealed {
541        type Value;
542    }
543    /// Empty state - all required fields are unset
544    pub struct Empty(());
545    impl sealed::Sealed for Empty {}
546    impl State for Empty {
547        type Value = Unset;
548    }
549    ///State transition - sets the `value` field to Set
550    pub struct SetValue<S: State = Empty>(PhantomData<fn() -> S>);
551    impl<S: State> sealed::Sealed for SetValue<S> {}
552    impl<S: State> State for SetValue<S> {
553        type Value = Set<members::value>;
554    }
555    /// Marker types for field names
556    #[allow(non_camel_case_types)]
557    pub mod members {
558        ///Marker type for the `value` field
559        pub struct value(());
560    }
561}
562
563/// Builder for constructing an instance of this type
564pub struct CursorSideBuilder<'a, S: cursor_side_state::State> {
565    _state: PhantomData<fn() -> S>,
566    _fields: (Option<i64>,),
567    _lifetime: PhantomData<&'a ()>,
568}
569
570impl<'a> CursorSide<'a> {
571    /// Create a new builder for this type
572    pub fn new() -> CursorSideBuilder<'a, cursor_side_state::Empty> {
573        CursorSideBuilder::new()
574    }
575}
576
577impl<'a> CursorSideBuilder<'a, cursor_side_state::Empty> {
578    /// Create a new builder with all fields unset
579    pub fn new() -> Self {
580        CursorSideBuilder {
581            _state: PhantomData,
582            _fields: (None,),
583            _lifetime: PhantomData,
584        }
585    }
586}
587
588impl<'a, S> CursorSideBuilder<'a, S>
589where
590    S: cursor_side_state::State,
591    S::Value: cursor_side_state::IsUnset,
592{
593    /// Set the `value` field (required)
594    pub fn value(
595        mut self,
596        value: impl Into<i64>,
597    ) -> CursorSideBuilder<'a, cursor_side_state::SetValue<S>> {
598        self._fields.0 = Option::Some(value.into());
599        CursorSideBuilder {
600            _state: PhantomData,
601            _fields: self._fields,
602            _lifetime: PhantomData,
603        }
604    }
605}
606
607impl<'a, S> CursorSideBuilder<'a, S>
608where
609    S: cursor_side_state::State,
610    S::Value: cursor_side_state::IsSet,
611{
612    /// Build the final struct
613    pub fn build(self) -> CursorSide<'a> {
614        CursorSide {
615            value: self._fields.0.unwrap(),
616            extra_data: Default::default(),
617        }
618    }
619    /// Build the final struct with custom extra_data
620    pub fn build_with_data(
621        self,
622        extra_data: BTreeMap<
623            jacquard_common::deps::smol_str::SmolStr,
624            jacquard_common::types::value::Data<'a>,
625        >,
626    ) -> CursorSide<'a> {
627        CursorSide {
628            value: self._fields.0.unwrap(),
629            extra_data: Some(extra_data),
630        }
631    }
632}
633
634pub mod id_state {
635
636    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
637    #[allow(unused)]
638    use ::core::marker::PhantomData;
639    mod sealed {
640        pub trait Sealed {}
641    }
642    /// State trait tracking which required fields have been set
643    pub trait State: sealed::Sealed {
644        type Peer;
645        type Counter;
646    }
647    /// Empty state - all required fields are unset
648    pub struct Empty(());
649    impl sealed::Sealed for Empty {}
650    impl State for Empty {
651        type Peer = Unset;
652        type Counter = Unset;
653    }
654    ///State transition - sets the `peer` field to Set
655    pub struct SetPeer<S: State = Empty>(PhantomData<fn() -> S>);
656    impl<S: State> sealed::Sealed for SetPeer<S> {}
657    impl<S: State> State for SetPeer<S> {
658        type Peer = Set<members::peer>;
659        type Counter = S::Counter;
660    }
661    ///State transition - sets the `counter` field to Set
662    pub struct SetCounter<S: State = Empty>(PhantomData<fn() -> S>);
663    impl<S: State> sealed::Sealed for SetCounter<S> {}
664    impl<S: State> State for SetCounter<S> {
665        type Peer = S::Peer;
666        type Counter = Set<members::counter>;
667    }
668    /// Marker types for field names
669    #[allow(non_camel_case_types)]
670    pub mod members {
671        ///Marker type for the `peer` field
672        pub struct peer(());
673        ///Marker type for the `counter` field
674        pub struct counter(());
675    }
676}
677
678/// Builder for constructing an instance of this type
679pub struct IdBuilder<'a, S: id_state::State> {
680    _state: PhantomData<fn() -> S>,
681    _fields: (Option<i64>, Option<i64>),
682    _lifetime: PhantomData<&'a ()>,
683}
684
685impl<'a> Id<'a> {
686    /// Create a new builder for this type
687    pub fn new() -> IdBuilder<'a, id_state::Empty> {
688        IdBuilder::new()
689    }
690}
691
692impl<'a> IdBuilder<'a, id_state::Empty> {
693    /// Create a new builder with all fields unset
694    pub fn new() -> Self {
695        IdBuilder {
696            _state: PhantomData,
697            _fields: (None, None),
698            _lifetime: PhantomData,
699        }
700    }
701}
702
703impl<'a, S> IdBuilder<'a, S>
704where
705    S: id_state::State,
706    S::Counter: id_state::IsUnset,
707{
708    /// Set the `counter` field (required)
709    pub fn counter(
710        mut self,
711        value: impl Into<i64>,
712    ) -> IdBuilder<'a, id_state::SetCounter<S>> {
713        self._fields.0 = Option::Some(value.into());
714        IdBuilder {
715            _state: PhantomData,
716            _fields: self._fields,
717            _lifetime: PhantomData,
718        }
719    }
720}
721
722impl<'a, S> IdBuilder<'a, S>
723where
724    S: id_state::State,
725    S::Peer: id_state::IsUnset,
726{
727    /// Set the `peer` field (required)
728    pub fn peer(mut self, value: impl Into<i64>) -> IdBuilder<'a, id_state::SetPeer<S>> {
729        self._fields.1 = Option::Some(value.into());
730        IdBuilder {
731            _state: PhantomData,
732            _fields: self._fields,
733            _lifetime: PhantomData,
734        }
735    }
736}
737
738impl<'a, S> IdBuilder<'a, S>
739where
740    S: id_state::State,
741    S::Peer: id_state::IsSet,
742    S::Counter: id_state::IsSet,
743{
744    /// Build the final struct
745    pub fn build(self) -> Id<'a> {
746        Id {
747            counter: self._fields.0.unwrap(),
748            peer: self._fields.1.unwrap(),
749            extra_data: Default::default(),
750        }
751    }
752    /// Build the final struct with custom extra_data
753    pub fn build_with_data(
754        self,
755        extra_data: BTreeMap<
756            jacquard_common::deps::smol_str::SmolStr,
757            jacquard_common::types::value::Data<'a>,
758        >,
759    ) -> Id<'a> {
760        Id {
761            counter: self._fields.0.unwrap(),
762            peer: self._fields.1.unwrap(),
763            extra_data: Some(extra_data),
764        }
765    }
766}
767
768pub mod cursor_state {
769
770    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
771    #[allow(unused)]
772    use ::core::marker::PhantomData;
773    mod sealed {
774        pub trait Sealed {}
775    }
776    /// State trait tracking which required fields have been set
777    pub trait State: sealed::Sealed {
778        type Container;
779        type Id;
780    }
781    /// Empty state - all required fields are unset
782    pub struct Empty(());
783    impl sealed::Sealed for Empty {}
784    impl State for Empty {
785        type Container = Unset;
786        type Id = Unset;
787    }
788    ///State transition - sets the `container` field to Set
789    pub struct SetContainer<S: State = Empty>(PhantomData<fn() -> S>);
790    impl<S: State> sealed::Sealed for SetContainer<S> {}
791    impl<S: State> State for SetContainer<S> {
792        type Container = Set<members::container>;
793        type Id = S::Id;
794    }
795    ///State transition - sets the `id` field to Set
796    pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
797    impl<S: State> sealed::Sealed for SetId<S> {}
798    impl<S: State> State for SetId<S> {
799        type Container = S::Container;
800        type Id = Set<members::id>;
801    }
802    /// Marker types for field names
803    #[allow(non_camel_case_types)]
804    pub mod members {
805        ///Marker type for the `container` field
806        pub struct container(());
807        ///Marker type for the `id` field
808        pub struct id(());
809    }
810}
811
812/// Builder for constructing an instance of this type
813pub struct CursorBuilder<'a, S: cursor_state::State> {
814    _state: PhantomData<fn() -> S>,
815    _fields: (
816        Option<cursor::ContainerId<'a>>,
817        Option<cursor::Id<'a>>,
818        Option<cursor::CursorSide<'a>>,
819    ),
820    _lifetime: PhantomData<&'a ()>,
821}
822
823impl<'a> Cursor<'a> {
824    /// Create a new builder for this type
825    pub fn new() -> CursorBuilder<'a, cursor_state::Empty> {
826        CursorBuilder::new()
827    }
828}
829
830impl<'a> CursorBuilder<'a, cursor_state::Empty> {
831    /// Create a new builder with all fields unset
832    pub fn new() -> Self {
833        CursorBuilder {
834            _state: PhantomData,
835            _fields: (None, None, None),
836            _lifetime: PhantomData,
837        }
838    }
839}
840
841impl<'a, S> CursorBuilder<'a, S>
842where
843    S: cursor_state::State,
844    S::Container: cursor_state::IsUnset,
845{
846    /// Set the `container` field (required)
847    pub fn container(
848        mut self,
849        value: impl Into<cursor::ContainerId<'a>>,
850    ) -> CursorBuilder<'a, cursor_state::SetContainer<S>> {
851        self._fields.0 = Option::Some(value.into());
852        CursorBuilder {
853            _state: PhantomData,
854            _fields: self._fields,
855            _lifetime: PhantomData,
856        }
857    }
858}
859
860impl<'a, S> CursorBuilder<'a, S>
861where
862    S: cursor_state::State,
863    S::Id: cursor_state::IsUnset,
864{
865    /// Set the `id` field (required)
866    pub fn id(
867        mut self,
868        value: impl Into<cursor::Id<'a>>,
869    ) -> CursorBuilder<'a, cursor_state::SetId<S>> {
870        self._fields.1 = Option::Some(value.into());
871        CursorBuilder {
872            _state: PhantomData,
873            _fields: self._fields,
874            _lifetime: PhantomData,
875        }
876    }
877}
878
879impl<'a, S: cursor_state::State> CursorBuilder<'a, S> {
880    /// Set the `side` field (optional)
881    pub fn side(mut self, value: impl Into<Option<cursor::CursorSide<'a>>>) -> Self {
882        self._fields.2 = value.into();
883        self
884    }
885    /// Set the `side` field to an Option value (optional)
886    pub fn maybe_side(mut self, value: Option<cursor::CursorSide<'a>>) -> Self {
887        self._fields.2 = value;
888        self
889    }
890}
891
892impl<'a, S> CursorBuilder<'a, S>
893where
894    S: cursor_state::State,
895    S::Container: cursor_state::IsSet,
896    S::Id: cursor_state::IsSet,
897{
898    /// Build the final struct
899    pub fn build(self) -> Cursor<'a> {
900        Cursor {
901            container: self._fields.0.unwrap(),
902            id: self._fields.1.unwrap(),
903            side: self._fields.2,
904            extra_data: Default::default(),
905        }
906    }
907    /// Build the final struct with custom extra_data
908    pub fn build_with_data(
909        self,
910        extra_data: BTreeMap<
911            jacquard_common::deps::smol_str::SmolStr,
912            jacquard_common::types::value::Data<'a>,
913        >,
914    ) -> Cursor<'a> {
915        Cursor {
916            container: self._fields.0.unwrap(),
917            id: self._fields.1.unwrap(),
918            side: self._fields.2,
919            extra_data: Some(extra_data),
920        }
921    }
922}
923
924pub mod normal_container_id_state {
925
926    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
927    #[allow(unused)]
928    use ::core::marker::PhantomData;
929    mod sealed {
930        pub trait Sealed {}
931    }
932    /// State trait tracking which required fields have been set
933    pub trait State: sealed::Sealed {
934        type ContainerType;
935        type Counter;
936        type Peer;
937    }
938    /// Empty state - all required fields are unset
939    pub struct Empty(());
940    impl sealed::Sealed for Empty {}
941    impl State for Empty {
942        type ContainerType = Unset;
943        type Counter = Unset;
944        type Peer = Unset;
945    }
946    ///State transition - sets the `container_type` field to Set
947    pub struct SetContainerType<S: State = Empty>(PhantomData<fn() -> S>);
948    impl<S: State> sealed::Sealed for SetContainerType<S> {}
949    impl<S: State> State for SetContainerType<S> {
950        type ContainerType = Set<members::container_type>;
951        type Counter = S::Counter;
952        type Peer = S::Peer;
953    }
954    ///State transition - sets the `counter` field to Set
955    pub struct SetCounter<S: State = Empty>(PhantomData<fn() -> S>);
956    impl<S: State> sealed::Sealed for SetCounter<S> {}
957    impl<S: State> State for SetCounter<S> {
958        type ContainerType = S::ContainerType;
959        type Counter = Set<members::counter>;
960        type Peer = S::Peer;
961    }
962    ///State transition - sets the `peer` field to Set
963    pub struct SetPeer<S: State = Empty>(PhantomData<fn() -> S>);
964    impl<S: State> sealed::Sealed for SetPeer<S> {}
965    impl<S: State> State for SetPeer<S> {
966        type ContainerType = S::ContainerType;
967        type Counter = S::Counter;
968        type Peer = Set<members::peer>;
969    }
970    /// Marker types for field names
971    #[allow(non_camel_case_types)]
972    pub mod members {
973        ///Marker type for the `container_type` field
974        pub struct container_type(());
975        ///Marker type for the `counter` field
976        pub struct counter(());
977        ///Marker type for the `peer` field
978        pub struct peer(());
979    }
980}
981
982/// Builder for constructing an instance of this type
983pub struct NormalContainerIdBuilder<'a, S: normal_container_id_state::State> {
984    _state: PhantomData<fn() -> S>,
985    _fields: (Option<CowStr<'a>>, Option<i64>, Option<i64>),
986    _lifetime: PhantomData<&'a ()>,
987}
988
989impl<'a> NormalContainerId<'a> {
990    /// Create a new builder for this type
991    pub fn new() -> NormalContainerIdBuilder<'a, normal_container_id_state::Empty> {
992        NormalContainerIdBuilder::new()
993    }
994}
995
996impl<'a> NormalContainerIdBuilder<'a, normal_container_id_state::Empty> {
997    /// Create a new builder with all fields unset
998    pub fn new() -> Self {
999        NormalContainerIdBuilder {
1000            _state: PhantomData,
1001            _fields: (None, None, None),
1002            _lifetime: PhantomData,
1003        }
1004    }
1005}
1006
1007impl<'a, S> NormalContainerIdBuilder<'a, S>
1008where
1009    S: normal_container_id_state::State,
1010    S::ContainerType: normal_container_id_state::IsUnset,
1011{
1012    /// Set the `container_type` field (required)
1013    pub fn container_type(
1014        mut self,
1015        value: impl Into<CowStr<'a>>,
1016    ) -> NormalContainerIdBuilder<'a, normal_container_id_state::SetContainerType<S>> {
1017        self._fields.0 = Option::Some(value.into());
1018        NormalContainerIdBuilder {
1019            _state: PhantomData,
1020            _fields: self._fields,
1021            _lifetime: PhantomData,
1022        }
1023    }
1024}
1025
1026impl<'a, S> NormalContainerIdBuilder<'a, S>
1027where
1028    S: normal_container_id_state::State,
1029    S::Counter: normal_container_id_state::IsUnset,
1030{
1031    /// Set the `counter` field (required)
1032    pub fn counter(
1033        mut self,
1034        value: impl Into<i64>,
1035    ) -> NormalContainerIdBuilder<'a, normal_container_id_state::SetCounter<S>> {
1036        self._fields.1 = Option::Some(value.into());
1037        NormalContainerIdBuilder {
1038            _state: PhantomData,
1039            _fields: self._fields,
1040            _lifetime: PhantomData,
1041        }
1042    }
1043}
1044
1045impl<'a, S> NormalContainerIdBuilder<'a, S>
1046where
1047    S: normal_container_id_state::State,
1048    S::Peer: normal_container_id_state::IsUnset,
1049{
1050    /// Set the `peer` field (required)
1051    pub fn peer(
1052        mut self,
1053        value: impl Into<i64>,
1054    ) -> NormalContainerIdBuilder<'a, normal_container_id_state::SetPeer<S>> {
1055        self._fields.2 = Option::Some(value.into());
1056        NormalContainerIdBuilder {
1057            _state: PhantomData,
1058            _fields: self._fields,
1059            _lifetime: PhantomData,
1060        }
1061    }
1062}
1063
1064impl<'a, S> NormalContainerIdBuilder<'a, S>
1065where
1066    S: normal_container_id_state::State,
1067    S::ContainerType: normal_container_id_state::IsSet,
1068    S::Counter: normal_container_id_state::IsSet,
1069    S::Peer: normal_container_id_state::IsSet,
1070{
1071    /// Build the final struct
1072    pub fn build(self) -> NormalContainerId<'a> {
1073        NormalContainerId {
1074            container_type: self._fields.0.unwrap(),
1075            counter: self._fields.1.unwrap(),
1076            peer: self._fields.2.unwrap(),
1077            extra_data: Default::default(),
1078        }
1079    }
1080    /// Build the final struct with custom extra_data
1081    pub fn build_with_data(
1082        self,
1083        extra_data: BTreeMap<
1084            jacquard_common::deps::smol_str::SmolStr,
1085            jacquard_common::types::value::Data<'a>,
1086        >,
1087    ) -> NormalContainerId<'a> {
1088        NormalContainerId {
1089            container_type: self._fields.0.unwrap(),
1090            counter: self._fields.1.unwrap(),
1091            peer: self._fields.2.unwrap(),
1092            extra_data: Some(extra_data),
1093        }
1094    }
1095}