Skip to main content

jacquard_api/sh_tangled/repo/
pull.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.tangled.repo.pull
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod comment;
9pub mod status;
10
11
12#[allow(unused_imports)]
13use alloc::collections::BTreeMap;
14
15#[allow(unused_imports)]
16use core::marker::PhantomData;
17use jacquard_common::CowStr;
18
19#[allow(unused_imports)]
20use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
21use jacquard_common::types::blob::BlobRef;
22use jacquard_common::types::collection::{Collection, RecordError};
23use jacquard_common::types::string::{Did, AtUri, Cid, Datetime};
24use jacquard_common::types::uri::{RecordUri, UriError};
25use jacquard_common::xrpc::XrpcResp;
26use jacquard_derive::{IntoStatic, lexicon};
27use jacquard_lexicon::lexicon::LexiconDoc;
28use jacquard_lexicon::schema::LexiconSchema;
29
30#[allow(unused_imports)]
31use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
32use serde::{Serialize, Deserialize};
33use crate::sh_tangled::repo::pull;
34
35#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase", rename = "sh.tangled.repo.pull", tag = "$type")]
38pub struct Pull<'a> {
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(borrow)]
41    pub body: Option<CowStr<'a>>,
42    pub created_at: Datetime,
43    #[serde(skip_serializing_if = "Option::is_none")]
44    #[serde(borrow)]
45    pub mentions: Option<Vec<Did<'a>>>,
46    ///(deprecated) use patchBlob instead
47    #[serde(skip_serializing_if = "Option::is_none")]
48    #[serde(borrow)]
49    pub patch: Option<CowStr<'a>>,
50    ///patch content
51    #[serde(borrow)]
52    pub patch_blob: BlobRef<'a>,
53    #[serde(skip_serializing_if = "Option::is_none")]
54    #[serde(borrow)]
55    pub references: Option<Vec<AtUri<'a>>>,
56    #[serde(skip_serializing_if = "Option::is_none")]
57    #[serde(borrow)]
58    pub source: Option<pull::Source<'a>>,
59    #[serde(borrow)]
60    pub target: pull::Target<'a>,
61    #[serde(borrow)]
62    pub title: CowStr<'a>,
63}
64
65/// Typed wrapper for GetRecord response with this collection's record type.
66
67#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
68#[serde(rename_all = "camelCase")]
69pub struct PullGetRecordOutput<'a> {
70    #[serde(skip_serializing_if = "Option::is_none")]
71    #[serde(borrow)]
72    pub cid: Option<Cid<'a>>,
73    #[serde(borrow)]
74    pub uri: AtUri<'a>,
75    #[serde(borrow)]
76    pub value: Pull<'a>,
77}
78
79
80#[lexicon]
81#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
82#[serde(rename_all = "camelCase")]
83pub struct Source<'a> {
84    #[serde(borrow)]
85    pub branch: CowStr<'a>,
86    #[serde(skip_serializing_if = "Option::is_none")]
87    #[serde(borrow)]
88    pub repo: Option<AtUri<'a>>,
89    #[serde(borrow)]
90    pub sha: CowStr<'a>,
91}
92
93
94#[lexicon]
95#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
96#[serde(rename_all = "camelCase")]
97pub struct Target<'a> {
98    #[serde(borrow)]
99    pub branch: CowStr<'a>,
100    #[serde(borrow)]
101    pub repo: AtUri<'a>,
102}
103
104impl<'a> Pull<'a> {
105    pub fn uri(
106        uri: impl Into<CowStr<'a>>,
107    ) -> Result<RecordUri<'a, PullRecord>, UriError> {
108        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
109    }
110}
111
112/// Marker type for deserializing records from this collection.
113
114#[derive(Debug, Serialize, Deserialize)]
115pub struct PullRecord;
116impl XrpcResp for PullRecord {
117    const NSID: &'static str = "sh.tangled.repo.pull";
118    const ENCODING: &'static str = "application/json";
119    type Output<'de> = PullGetRecordOutput<'de>;
120    type Err<'de> = RecordError<'de>;
121}
122
123impl From<PullGetRecordOutput<'_>> for Pull<'_> {
124    fn from(output: PullGetRecordOutput<'_>) -> Self {
125        use jacquard_common::IntoStatic;
126        output.value.into_static()
127    }
128}
129
130impl Collection for Pull<'_> {
131    const NSID: &'static str = "sh.tangled.repo.pull";
132    type Record = PullRecord;
133}
134
135impl Collection for PullRecord {
136    const NSID: &'static str = "sh.tangled.repo.pull";
137    type Record = PullRecord;
138}
139
140impl<'a> LexiconSchema for Pull<'a> {
141    fn nsid() -> &'static str {
142        "sh.tangled.repo.pull"
143    }
144    fn def_name() -> &'static str {
145        "main"
146    }
147    fn lexicon_doc() -> LexiconDoc<'static> {
148        lexicon_doc_sh_tangled_repo_pull()
149    }
150    fn validate(&self) -> Result<(), ConstraintError> {
151        {
152            let value = &self.patch_blob;
153            {
154                let mime = value.blob().mime_type.as_str();
155                let accepted: &[&str] = &["text/x-patch"];
156                let matched = accepted
157                    .iter()
158                    .any(|pattern| {
159                        if *pattern == "*/*" {
160                            true
161                        } else if pattern.ends_with("/*") {
162                            let prefix = &pattern[..pattern.len() - 2];
163                            mime.starts_with(prefix)
164                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
165                        } else {
166                            mime == *pattern
167                        }
168                    });
169                if !matched {
170                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
171                        path: ValidationPath::from_field("patch_blob"),
172                        accepted: vec!["text/x-patch".to_string()],
173                        actual: mime.to_string(),
174                    });
175                }
176            }
177        }
178        Ok(())
179    }
180}
181
182impl<'a> LexiconSchema for Source<'a> {
183    fn nsid() -> &'static str {
184        "sh.tangled.repo.pull"
185    }
186    fn def_name() -> &'static str {
187        "source"
188    }
189    fn lexicon_doc() -> LexiconDoc<'static> {
190        lexicon_doc_sh_tangled_repo_pull()
191    }
192    fn validate(&self) -> Result<(), ConstraintError> {
193        {
194            let value = &self.sha;
195            #[allow(unused_comparisons)]
196            if <str>::len(value.as_ref()) > 40usize {
197                return Err(ConstraintError::MaxLength {
198                    path: ValidationPath::from_field("sha"),
199                    max: 40usize,
200                    actual: <str>::len(value.as_ref()),
201                });
202            }
203        }
204        {
205            let value = &self.sha;
206            #[allow(unused_comparisons)]
207            if <str>::len(value.as_ref()) < 40usize {
208                return Err(ConstraintError::MinLength {
209                    path: ValidationPath::from_field("sha"),
210                    min: 40usize,
211                    actual: <str>::len(value.as_ref()),
212                });
213            }
214        }
215        Ok(())
216    }
217}
218
219impl<'a> LexiconSchema for Target<'a> {
220    fn nsid() -> &'static str {
221        "sh.tangled.repo.pull"
222    }
223    fn def_name() -> &'static str {
224        "target"
225    }
226    fn lexicon_doc() -> LexiconDoc<'static> {
227        lexicon_doc_sh_tangled_repo_pull()
228    }
229    fn validate(&self) -> Result<(), ConstraintError> {
230        Ok(())
231    }
232}
233
234pub mod pull_state {
235
236    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
237    #[allow(unused)]
238    use ::core::marker::PhantomData;
239    mod sealed {
240        pub trait Sealed {}
241    }
242    /// State trait tracking which required fields have been set
243    pub trait State: sealed::Sealed {
244        type Target;
245        type PatchBlob;
246        type CreatedAt;
247        type Title;
248    }
249    /// Empty state - all required fields are unset
250    pub struct Empty(());
251    impl sealed::Sealed for Empty {}
252    impl State for Empty {
253        type Target = Unset;
254        type PatchBlob = Unset;
255        type CreatedAt = Unset;
256        type Title = Unset;
257    }
258    ///State transition - sets the `target` field to Set
259    pub struct SetTarget<S: State = Empty>(PhantomData<fn() -> S>);
260    impl<S: State> sealed::Sealed for SetTarget<S> {}
261    impl<S: State> State for SetTarget<S> {
262        type Target = Set<members::target>;
263        type PatchBlob = S::PatchBlob;
264        type CreatedAt = S::CreatedAt;
265        type Title = S::Title;
266    }
267    ///State transition - sets the `patch_blob` field to Set
268    pub struct SetPatchBlob<S: State = Empty>(PhantomData<fn() -> S>);
269    impl<S: State> sealed::Sealed for SetPatchBlob<S> {}
270    impl<S: State> State for SetPatchBlob<S> {
271        type Target = S::Target;
272        type PatchBlob = Set<members::patch_blob>;
273        type CreatedAt = S::CreatedAt;
274        type Title = S::Title;
275    }
276    ///State transition - sets the `created_at` field to Set
277    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
278    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
279    impl<S: State> State for SetCreatedAt<S> {
280        type Target = S::Target;
281        type PatchBlob = S::PatchBlob;
282        type CreatedAt = Set<members::created_at>;
283        type Title = S::Title;
284    }
285    ///State transition - sets the `title` field to Set
286    pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
287    impl<S: State> sealed::Sealed for SetTitle<S> {}
288    impl<S: State> State for SetTitle<S> {
289        type Target = S::Target;
290        type PatchBlob = S::PatchBlob;
291        type CreatedAt = S::CreatedAt;
292        type Title = Set<members::title>;
293    }
294    /// Marker types for field names
295    #[allow(non_camel_case_types)]
296    pub mod members {
297        ///Marker type for the `target` field
298        pub struct target(());
299        ///Marker type for the `patch_blob` field
300        pub struct patch_blob(());
301        ///Marker type for the `created_at` field
302        pub struct created_at(());
303        ///Marker type for the `title` field
304        pub struct title(());
305    }
306}
307
308/// Builder for constructing an instance of this type
309pub struct PullBuilder<'a, S: pull_state::State> {
310    _state: PhantomData<fn() -> S>,
311    _fields: (
312        Option<CowStr<'a>>,
313        Option<Datetime>,
314        Option<Vec<Did<'a>>>,
315        Option<CowStr<'a>>,
316        Option<BlobRef<'a>>,
317        Option<Vec<AtUri<'a>>>,
318        Option<pull::Source<'a>>,
319        Option<pull::Target<'a>>,
320        Option<CowStr<'a>>,
321    ),
322    _lifetime: PhantomData<&'a ()>,
323}
324
325impl<'a> Pull<'a> {
326    /// Create a new builder for this type
327    pub fn new() -> PullBuilder<'a, pull_state::Empty> {
328        PullBuilder::new()
329    }
330}
331
332impl<'a> PullBuilder<'a, pull_state::Empty> {
333    /// Create a new builder with all fields unset
334    pub fn new() -> Self {
335        PullBuilder {
336            _state: PhantomData,
337            _fields: (None, None, None, None, None, None, None, None, None),
338            _lifetime: PhantomData,
339        }
340    }
341}
342
343impl<'a, S: pull_state::State> PullBuilder<'a, S> {
344    /// Set the `body` field (optional)
345    pub fn body(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
346        self._fields.0 = value.into();
347        self
348    }
349    /// Set the `body` field to an Option value (optional)
350    pub fn maybe_body(mut self, value: Option<CowStr<'a>>) -> Self {
351        self._fields.0 = value;
352        self
353    }
354}
355
356impl<'a, S> PullBuilder<'a, S>
357where
358    S: pull_state::State,
359    S::CreatedAt: pull_state::IsUnset,
360{
361    /// Set the `createdAt` field (required)
362    pub fn created_at(
363        mut self,
364        value: impl Into<Datetime>,
365    ) -> PullBuilder<'a, pull_state::SetCreatedAt<S>> {
366        self._fields.1 = Option::Some(value.into());
367        PullBuilder {
368            _state: PhantomData,
369            _fields: self._fields,
370            _lifetime: PhantomData,
371        }
372    }
373}
374
375impl<'a, S: pull_state::State> PullBuilder<'a, S> {
376    /// Set the `mentions` field (optional)
377    pub fn mentions(mut self, value: impl Into<Option<Vec<Did<'a>>>>) -> Self {
378        self._fields.2 = value.into();
379        self
380    }
381    /// Set the `mentions` field to an Option value (optional)
382    pub fn maybe_mentions(mut self, value: Option<Vec<Did<'a>>>) -> Self {
383        self._fields.2 = value;
384        self
385    }
386}
387
388impl<'a, S: pull_state::State> PullBuilder<'a, S> {
389    /// Set the `patch` field (optional)
390    pub fn patch(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
391        self._fields.3 = value.into();
392        self
393    }
394    /// Set the `patch` field to an Option value (optional)
395    pub fn maybe_patch(mut self, value: Option<CowStr<'a>>) -> Self {
396        self._fields.3 = value;
397        self
398    }
399}
400
401impl<'a, S> PullBuilder<'a, S>
402where
403    S: pull_state::State,
404    S::PatchBlob: pull_state::IsUnset,
405{
406    /// Set the `patchBlob` field (required)
407    pub fn patch_blob(
408        mut self,
409        value: impl Into<BlobRef<'a>>,
410    ) -> PullBuilder<'a, pull_state::SetPatchBlob<S>> {
411        self._fields.4 = Option::Some(value.into());
412        PullBuilder {
413            _state: PhantomData,
414            _fields: self._fields,
415            _lifetime: PhantomData,
416        }
417    }
418}
419
420impl<'a, S: pull_state::State> PullBuilder<'a, S> {
421    /// Set the `references` field (optional)
422    pub fn references(mut self, value: impl Into<Option<Vec<AtUri<'a>>>>) -> Self {
423        self._fields.5 = value.into();
424        self
425    }
426    /// Set the `references` field to an Option value (optional)
427    pub fn maybe_references(mut self, value: Option<Vec<AtUri<'a>>>) -> Self {
428        self._fields.5 = value;
429        self
430    }
431}
432
433impl<'a, S: pull_state::State> PullBuilder<'a, S> {
434    /// Set the `source` field (optional)
435    pub fn source(mut self, value: impl Into<Option<pull::Source<'a>>>) -> Self {
436        self._fields.6 = value.into();
437        self
438    }
439    /// Set the `source` field to an Option value (optional)
440    pub fn maybe_source(mut self, value: Option<pull::Source<'a>>) -> Self {
441        self._fields.6 = value;
442        self
443    }
444}
445
446impl<'a, S> PullBuilder<'a, S>
447where
448    S: pull_state::State,
449    S::Target: pull_state::IsUnset,
450{
451    /// Set the `target` field (required)
452    pub fn target(
453        mut self,
454        value: impl Into<pull::Target<'a>>,
455    ) -> PullBuilder<'a, pull_state::SetTarget<S>> {
456        self._fields.7 = Option::Some(value.into());
457        PullBuilder {
458            _state: PhantomData,
459            _fields: self._fields,
460            _lifetime: PhantomData,
461        }
462    }
463}
464
465impl<'a, S> PullBuilder<'a, S>
466where
467    S: pull_state::State,
468    S::Title: pull_state::IsUnset,
469{
470    /// Set the `title` field (required)
471    pub fn title(
472        mut self,
473        value: impl Into<CowStr<'a>>,
474    ) -> PullBuilder<'a, pull_state::SetTitle<S>> {
475        self._fields.8 = Option::Some(value.into());
476        PullBuilder {
477            _state: PhantomData,
478            _fields: self._fields,
479            _lifetime: PhantomData,
480        }
481    }
482}
483
484impl<'a, S> PullBuilder<'a, S>
485where
486    S: pull_state::State,
487    S::Target: pull_state::IsSet,
488    S::PatchBlob: pull_state::IsSet,
489    S::CreatedAt: pull_state::IsSet,
490    S::Title: pull_state::IsSet,
491{
492    /// Build the final struct
493    pub fn build(self) -> Pull<'a> {
494        Pull {
495            body: self._fields.0,
496            created_at: self._fields.1.unwrap(),
497            mentions: self._fields.2,
498            patch: self._fields.3,
499            patch_blob: self._fields.4.unwrap(),
500            references: self._fields.5,
501            source: self._fields.6,
502            target: self._fields.7.unwrap(),
503            title: self._fields.8.unwrap(),
504            extra_data: Default::default(),
505        }
506    }
507    /// Build the final struct with custom extra_data
508    pub fn build_with_data(
509        self,
510        extra_data: BTreeMap<
511            jacquard_common::deps::smol_str::SmolStr,
512            jacquard_common::types::value::Data<'a>,
513        >,
514    ) -> Pull<'a> {
515        Pull {
516            body: self._fields.0,
517            created_at: self._fields.1.unwrap(),
518            mentions: self._fields.2,
519            patch: self._fields.3,
520            patch_blob: self._fields.4.unwrap(),
521            references: self._fields.5,
522            source: self._fields.6,
523            target: self._fields.7.unwrap(),
524            title: self._fields.8.unwrap(),
525            extra_data: Some(extra_data),
526        }
527    }
528}
529
530fn lexicon_doc_sh_tangled_repo_pull() -> LexiconDoc<'static> {
531    #[allow(unused_imports)]
532    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
533    use jacquard_lexicon::lexicon::*;
534    use alloc::collections::BTreeMap;
535    LexiconDoc {
536        lexicon: Lexicon::Lexicon1,
537        id: CowStr::new_static("sh.tangled.repo.pull"),
538        defs: {
539            let mut map = BTreeMap::new();
540            map.insert(
541                SmolStr::new_static("main"),
542                LexUserType::Record(LexRecord {
543                    key: Some(CowStr::new_static("tid")),
544                    record: LexRecordRecord::Object(LexObject {
545                        required: Some(
546                            vec![
547                                SmolStr::new_static("target"), SmolStr::new_static("title"),
548                                SmolStr::new_static("patchBlob"),
549                                SmolStr::new_static("createdAt")
550                            ],
551                        ),
552                        properties: {
553                            #[allow(unused_mut)]
554                            let mut map = BTreeMap::new();
555                            map.insert(
556                                SmolStr::new_static("body"),
557                                LexObjectProperty::String(LexString {
558                                    ..Default::default()
559                                }),
560                            );
561                            map.insert(
562                                SmolStr::new_static("createdAt"),
563                                LexObjectProperty::String(LexString {
564                                    format: Some(LexStringFormat::Datetime),
565                                    ..Default::default()
566                                }),
567                            );
568                            map.insert(
569                                SmolStr::new_static("mentions"),
570                                LexObjectProperty::Array(LexArray {
571                                    items: LexArrayItem::String(LexString {
572                                        format: Some(LexStringFormat::Did),
573                                        ..Default::default()
574                                    }),
575                                    ..Default::default()
576                                }),
577                            );
578                            map.insert(
579                                SmolStr::new_static("patch"),
580                                LexObjectProperty::String(LexString {
581                                    description: Some(
582                                        CowStr::new_static("(deprecated) use patchBlob instead"),
583                                    ),
584                                    ..Default::default()
585                                }),
586                            );
587                            map.insert(
588                                SmolStr::new_static("patchBlob"),
589                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
590                            );
591                            map.insert(
592                                SmolStr::new_static("references"),
593                                LexObjectProperty::Array(LexArray {
594                                    items: LexArrayItem::String(LexString {
595                                        format: Some(LexStringFormat::AtUri),
596                                        ..Default::default()
597                                    }),
598                                    ..Default::default()
599                                }),
600                            );
601                            map.insert(
602                                SmolStr::new_static("source"),
603                                LexObjectProperty::Ref(LexRef {
604                                    r#ref: CowStr::new_static("#source"),
605                                    ..Default::default()
606                                }),
607                            );
608                            map.insert(
609                                SmolStr::new_static("target"),
610                                LexObjectProperty::Ref(LexRef {
611                                    r#ref: CowStr::new_static("#target"),
612                                    ..Default::default()
613                                }),
614                            );
615                            map.insert(
616                                SmolStr::new_static("title"),
617                                LexObjectProperty::String(LexString {
618                                    ..Default::default()
619                                }),
620                            );
621                            map
622                        },
623                        ..Default::default()
624                    }),
625                    ..Default::default()
626                }),
627            );
628            map.insert(
629                SmolStr::new_static("source"),
630                LexUserType::Object(LexObject {
631                    required: Some(
632                        vec![SmolStr::new_static("branch"), SmolStr::new_static("sha")],
633                    ),
634                    properties: {
635                        #[allow(unused_mut)]
636                        let mut map = BTreeMap::new();
637                        map.insert(
638                            SmolStr::new_static("branch"),
639                            LexObjectProperty::String(LexString { ..Default::default() }),
640                        );
641                        map.insert(
642                            SmolStr::new_static("repo"),
643                            LexObjectProperty::String(LexString {
644                                format: Some(LexStringFormat::AtUri),
645                                ..Default::default()
646                            }),
647                        );
648                        map.insert(
649                            SmolStr::new_static("sha"),
650                            LexObjectProperty::String(LexString {
651                                min_length: Some(40usize),
652                                max_length: Some(40usize),
653                                ..Default::default()
654                            }),
655                        );
656                        map
657                    },
658                    ..Default::default()
659                }),
660            );
661            map.insert(
662                SmolStr::new_static("target"),
663                LexUserType::Object(LexObject {
664                    required: Some(
665                        vec![SmolStr::new_static("repo"), SmolStr::new_static("branch")],
666                    ),
667                    properties: {
668                        #[allow(unused_mut)]
669                        let mut map = BTreeMap::new();
670                        map.insert(
671                            SmolStr::new_static("branch"),
672                            LexObjectProperty::String(LexString { ..Default::default() }),
673                        );
674                        map.insert(
675                            SmolStr::new_static("repo"),
676                            LexObjectProperty::String(LexString {
677                                format: Some(LexStringFormat::AtUri),
678                                ..Default::default()
679                            }),
680                        );
681                        map
682                    },
683                    ..Default::default()
684                }),
685            );
686            map
687        },
688        ..Default::default()
689    }
690}
691
692pub mod target_state {
693
694    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
695    #[allow(unused)]
696    use ::core::marker::PhantomData;
697    mod sealed {
698        pub trait Sealed {}
699    }
700    /// State trait tracking which required fields have been set
701    pub trait State: sealed::Sealed {
702        type Branch;
703        type Repo;
704    }
705    /// Empty state - all required fields are unset
706    pub struct Empty(());
707    impl sealed::Sealed for Empty {}
708    impl State for Empty {
709        type Branch = Unset;
710        type Repo = Unset;
711    }
712    ///State transition - sets the `branch` field to Set
713    pub struct SetBranch<S: State = Empty>(PhantomData<fn() -> S>);
714    impl<S: State> sealed::Sealed for SetBranch<S> {}
715    impl<S: State> State for SetBranch<S> {
716        type Branch = Set<members::branch>;
717        type Repo = S::Repo;
718    }
719    ///State transition - sets the `repo` field to Set
720    pub struct SetRepo<S: State = Empty>(PhantomData<fn() -> S>);
721    impl<S: State> sealed::Sealed for SetRepo<S> {}
722    impl<S: State> State for SetRepo<S> {
723        type Branch = S::Branch;
724        type Repo = Set<members::repo>;
725    }
726    /// Marker types for field names
727    #[allow(non_camel_case_types)]
728    pub mod members {
729        ///Marker type for the `branch` field
730        pub struct branch(());
731        ///Marker type for the `repo` field
732        pub struct repo(());
733    }
734}
735
736/// Builder for constructing an instance of this type
737pub struct TargetBuilder<'a, S: target_state::State> {
738    _state: PhantomData<fn() -> S>,
739    _fields: (Option<CowStr<'a>>, Option<AtUri<'a>>),
740    _lifetime: PhantomData<&'a ()>,
741}
742
743impl<'a> Target<'a> {
744    /// Create a new builder for this type
745    pub fn new() -> TargetBuilder<'a, target_state::Empty> {
746        TargetBuilder::new()
747    }
748}
749
750impl<'a> TargetBuilder<'a, target_state::Empty> {
751    /// Create a new builder with all fields unset
752    pub fn new() -> Self {
753        TargetBuilder {
754            _state: PhantomData,
755            _fields: (None, None),
756            _lifetime: PhantomData,
757        }
758    }
759}
760
761impl<'a, S> TargetBuilder<'a, S>
762where
763    S: target_state::State,
764    S::Branch: target_state::IsUnset,
765{
766    /// Set the `branch` field (required)
767    pub fn branch(
768        mut self,
769        value: impl Into<CowStr<'a>>,
770    ) -> TargetBuilder<'a, target_state::SetBranch<S>> {
771        self._fields.0 = Option::Some(value.into());
772        TargetBuilder {
773            _state: PhantomData,
774            _fields: self._fields,
775            _lifetime: PhantomData,
776        }
777    }
778}
779
780impl<'a, S> TargetBuilder<'a, S>
781where
782    S: target_state::State,
783    S::Repo: target_state::IsUnset,
784{
785    /// Set the `repo` field (required)
786    pub fn repo(
787        mut self,
788        value: impl Into<AtUri<'a>>,
789    ) -> TargetBuilder<'a, target_state::SetRepo<S>> {
790        self._fields.1 = Option::Some(value.into());
791        TargetBuilder {
792            _state: PhantomData,
793            _fields: self._fields,
794            _lifetime: PhantomData,
795        }
796    }
797}
798
799impl<'a, S> TargetBuilder<'a, S>
800where
801    S: target_state::State,
802    S::Branch: target_state::IsSet,
803    S::Repo: target_state::IsSet,
804{
805    /// Build the final struct
806    pub fn build(self) -> Target<'a> {
807        Target {
808            branch: self._fields.0.unwrap(),
809            repo: self._fields.1.unwrap(),
810            extra_data: Default::default(),
811        }
812    }
813    /// Build the final struct with custom extra_data
814    pub fn build_with_data(
815        self,
816        extra_data: BTreeMap<
817            jacquard_common::deps::smol_str::SmolStr,
818            jacquard_common::types::value::Data<'a>,
819        >,
820    ) -> Target<'a> {
821        Target {
822            branch: self._fields.0.unwrap(),
823            repo: self._fields.1.unwrap(),
824            extra_data: Some(extra_data),
825        }
826    }
827}