Skip to main content

jacquard_api/place_stream/
badge.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.badge.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8//! Generated bindings for the `place.stream.badge` Lexicon namespace/module.
9pub mod def;
10pub mod get_issued_badges;
11pub mod get_valid_badges;
12pub mod issuance;
13
14
15#[allow(unused_imports)]
16use alloc::collections::BTreeMap;
17
18#[allow(unused_imports)]
19use core::marker::PhantomData;
20use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
21
22#[allow(unused_imports)]
23use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
24use jacquard_common::deps::smol_str::SmolStr;
25use jacquard_common::types::string::{Did, AtUri, UriValue};
26use jacquard_common::types::value::Data;
27use jacquard_derive::IntoStatic;
28use jacquard_lexicon::lexicon::LexiconDoc;
29use jacquard_lexicon::schema::LexiconSchema;
30
31#[allow(unused_imports)]
32use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
33use serde::{Serialize, Deserialize};
34use crate::place_stream::badge;
35/// A resolved view of a badge issuance, including def fields for display.
36
37#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
38#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
39pub struct BadgeIssuanceView<S: BosStr = DefaultStr> {
40    pub badge_type: BadgeIssuanceViewBadgeType<S>,
41    ///Description from the badge definition.
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub description: Option<S>,
44    ///Resolved image URL for the badge icon.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub image_url: Option<UriValue<S>>,
47    ///CID of the place.stream.badge.issuance record.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub issuance_cid: Option<S>,
50    ///AT URI of the place.stream.badge.issuance record.
51    pub issuance_uri: AtUri<S>,
52    ///DID of the badge issuer.
53    pub issuer: Did<S>,
54    ///Display name from the badge definition.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub name: Option<S>,
57    ///Whether this badge is currently in the user's chat profile selection.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub selected: Option<bool>,
60    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
61    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
62}
63
64
65#[derive(Debug, Clone, PartialEq, Eq, Hash)]
66pub enum BadgeIssuanceViewBadgeType<S: BosStr = DefaultStr> {
67    Vip,
68    Event,
69    Other(S),
70}
71
72impl<S: BosStr> BadgeIssuanceViewBadgeType<S> {
73    pub fn as_str(&self) -> &str {
74        match self {
75            Self::Vip => "place.stream.badge.defs#vip",
76            Self::Event => "place.stream.badge.defs#event",
77            Self::Other(s) => s.as_ref(),
78        }
79    }
80    /// Construct from a string-like value, matching known values.
81    pub fn from_value(s: S) -> Self {
82        match s.as_ref() {
83            "place.stream.badge.defs#vip" => Self::Vip,
84            "place.stream.badge.defs#event" => Self::Event,
85            _ => Self::Other(s),
86        }
87    }
88}
89
90impl<S: BosStr> core::fmt::Display for BadgeIssuanceViewBadgeType<S> {
91    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
92        write!(f, "{}", self.as_str())
93    }
94}
95
96impl<S: BosStr> AsRef<str> for BadgeIssuanceViewBadgeType<S> {
97    fn as_ref(&self) -> &str {
98        self.as_str()
99    }
100}
101
102impl<S: BosStr> Serialize for BadgeIssuanceViewBadgeType<S> {
103    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
104    where
105        Ser: serde::Serializer,
106    {
107        serializer.serialize_str(self.as_str())
108    }
109}
110
111impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
112for BadgeIssuanceViewBadgeType<S> {
113    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
114    where
115        D: serde::Deserializer<'de>,
116    {
117        let s = S::deserialize(deserializer)?;
118        Ok(Self::from_value(s))
119    }
120}
121
122impl<S: BosStr + Default> Default for BadgeIssuanceViewBadgeType<S> {
123    fn default() -> Self {
124        Self::Other(Default::default())
125    }
126}
127
128impl<S: BosStr> jacquard_common::IntoStatic for BadgeIssuanceViewBadgeType<S>
129where
130    S: BosStr + jacquard_common::IntoStatic,
131    S::Output: BosStr,
132{
133    type Output = BadgeIssuanceViewBadgeType<S::Output>;
134    fn into_static(self) -> Self::Output {
135        match self {
136            BadgeIssuanceViewBadgeType::Vip => BadgeIssuanceViewBadgeType::Vip,
137            BadgeIssuanceViewBadgeType::Event => BadgeIssuanceViewBadgeType::Event,
138            BadgeIssuanceViewBadgeType::Other(v) => {
139                BadgeIssuanceViewBadgeType::Other(v.into_static())
140            }
141        }
142    }
143}
144
145/// A display slot containing available issuance-based badges and which one (if any) is currently selected.
146
147#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
148#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
149pub struct BadgeSlot<S: BosStr = DefaultStr> {
150    ///All badges available for this slot.
151    pub available: Vec<badge::BadgeIssuanceView<S>>,
152    ///The currently selected badge in this slot, if any.
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub selected: Option<badge::BadgeIssuanceView<S>>,
155    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
156    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
157}
158
159/// View of a badge record, with fields resolved for display. If the DID in issuer is not the current streamplace node, the signature field shall be required.
160
161#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
162#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
163pub struct BadgeView<S: BosStr = DefaultStr> {
164    pub badge_type: BadgeViewBadgeType<S>,
165    ///Description from the badge definition.
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub description: Option<S>,
168    ///Resolved image URL for the badge icon.
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub image_url: Option<UriValue<S>>,
171    ///DID of the badge issuer.
172    pub issuer: Did<S>,
173    ///Display name from the badge definition.
174    #[serde(skip_serializing_if = "Option::is_none")]
175    pub name: Option<S>,
176    ///DID of the badge recipient.
177    pub recipient: Did<S>,
178    ///TODO: Cryptographic signature of the badge (of a place.stream.key).
179    #[serde(skip_serializing_if = "Option::is_none")]
180    pub signature: Option<S>,
181    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
182    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
183}
184
185
186#[derive(Debug, Clone, PartialEq, Eq, Hash)]
187pub enum BadgeViewBadgeType<S: BosStr = DefaultStr> {
188    Mod,
189    Streamer,
190    Vip,
191    Event,
192    Bot,
193    Other(S),
194}
195
196impl<S: BosStr> BadgeViewBadgeType<S> {
197    pub fn as_str(&self) -> &str {
198        match self {
199            Self::Mod => "place.stream.badge.defs#mod",
200            Self::Streamer => "place.stream.badge.defs#streamer",
201            Self::Vip => "place.stream.badge.defs#vip",
202            Self::Event => "place.stream.badge.defs#event",
203            Self::Bot => "place.stream.badge.defs#bot",
204            Self::Other(s) => s.as_ref(),
205        }
206    }
207    /// Construct from a string-like value, matching known values.
208    pub fn from_value(s: S) -> Self {
209        match s.as_ref() {
210            "place.stream.badge.defs#mod" => Self::Mod,
211            "place.stream.badge.defs#streamer" => Self::Streamer,
212            "place.stream.badge.defs#vip" => Self::Vip,
213            "place.stream.badge.defs#event" => Self::Event,
214            "place.stream.badge.defs#bot" => Self::Bot,
215            _ => Self::Other(s),
216        }
217    }
218}
219
220impl<S: BosStr> core::fmt::Display for BadgeViewBadgeType<S> {
221    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
222        write!(f, "{}", self.as_str())
223    }
224}
225
226impl<S: BosStr> AsRef<str> for BadgeViewBadgeType<S> {
227    fn as_ref(&self) -> &str {
228        self.as_str()
229    }
230}
231
232impl<S: BosStr> Serialize for BadgeViewBadgeType<S> {
233    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
234    where
235        Ser: serde::Serializer,
236    {
237        serializer.serialize_str(self.as_str())
238    }
239}
240
241impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for BadgeViewBadgeType<S> {
242    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
243    where
244        D: serde::Deserializer<'de>,
245    {
246        let s = S::deserialize(deserializer)?;
247        Ok(Self::from_value(s))
248    }
249}
250
251impl<S: BosStr + Default> Default for BadgeViewBadgeType<S> {
252    fn default() -> Self {
253        Self::Other(Default::default())
254    }
255}
256
257impl<S: BosStr> jacquard_common::IntoStatic for BadgeViewBadgeType<S>
258where
259    S: BosStr + jacquard_common::IntoStatic,
260    S::Output: BosStr,
261{
262    type Output = BadgeViewBadgeType<S::Output>;
263    fn into_static(self) -> Self::Output {
264        match self {
265            BadgeViewBadgeType::Mod => BadgeViewBadgeType::Mod,
266            BadgeViewBadgeType::Streamer => BadgeViewBadgeType::Streamer,
267            BadgeViewBadgeType::Vip => BadgeViewBadgeType::Vip,
268            BadgeViewBadgeType::Event => BadgeViewBadgeType::Event,
269            BadgeViewBadgeType::Bot => BadgeViewBadgeType::Bot,
270            BadgeViewBadgeType::Other(v) => BadgeViewBadgeType::Other(v.into_static()),
271        }
272    }
273}
274
275/// This user is a bot. Self-applied via place.stream.chat.profile selfLabels.
276
277#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
278pub struct Bot;
279impl core::fmt::Display for Bot {
280    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
281        write!(f, "bot")
282    }
283}
284
285/// This user has won or earned a special event or contest badge.
286
287#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
288pub struct Event;
289impl core::fmt::Display for Event {
290    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
291        write!(f, "event")
292    }
293}
294
295/// This user is a moderator. Displayed with a sword icon.
296
297#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
298pub struct Mod;
299impl core::fmt::Display for Mod {
300    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
301        write!(f, "mod")
302    }
303}
304
305/// This user is the streamer. Displayed with a star icon.
306
307#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
308pub struct Streamer;
309impl core::fmt::Display for Streamer {
310    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
311        write!(f, "streamer")
312    }
313}
314
315/// This user is a very important person.
316
317#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
318pub struct Vip;
319impl core::fmt::Display for Vip {
320    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
321        write!(f, "vip")
322    }
323}
324
325impl<S: BosStr> LexiconSchema for BadgeIssuanceView<S> {
326    fn nsid() -> &'static str {
327        "place.stream.badge.defs"
328    }
329    fn def_name() -> &'static str {
330        "badgeIssuanceView"
331    }
332    fn lexicon_doc() -> LexiconDoc<'static> {
333        lexicon_doc_place_stream_badge_defs()
334    }
335    fn validate(&self) -> Result<(), ConstraintError> {
336        Ok(())
337    }
338}
339
340impl<S: BosStr> LexiconSchema for BadgeSlot<S> {
341    fn nsid() -> &'static str {
342        "place.stream.badge.defs"
343    }
344    fn def_name() -> &'static str {
345        "badgeSlot"
346    }
347    fn lexicon_doc() -> LexiconDoc<'static> {
348        lexicon_doc_place_stream_badge_defs()
349    }
350    fn validate(&self) -> Result<(), ConstraintError> {
351        Ok(())
352    }
353}
354
355impl<S: BosStr> LexiconSchema for BadgeView<S> {
356    fn nsid() -> &'static str {
357        "place.stream.badge.defs"
358    }
359    fn def_name() -> &'static str {
360        "badgeView"
361    }
362    fn lexicon_doc() -> LexiconDoc<'static> {
363        lexicon_doc_place_stream_badge_defs()
364    }
365    fn validate(&self) -> Result<(), ConstraintError> {
366        Ok(())
367    }
368}
369
370pub mod badge_issuance_view_state {
371
372    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
373    #[allow(unused)]
374    use ::core::marker::PhantomData;
375    mod sealed {
376        pub trait Sealed {}
377    }
378    /// State trait tracking which required fields have been set
379    pub trait State: sealed::Sealed {
380        type BadgeType;
381        type IssuanceUri;
382        type Issuer;
383    }
384    /// Empty state - all required fields are unset
385    pub struct Empty(());
386    impl sealed::Sealed for Empty {}
387    impl State for Empty {
388        type BadgeType = Unset;
389        type IssuanceUri = Unset;
390        type Issuer = Unset;
391    }
392    ///State transition - sets the `badge_type` field to Set
393    pub struct SetBadgeType<St: State = Empty>(PhantomData<fn() -> St>);
394    impl<St: State> sealed::Sealed for SetBadgeType<St> {}
395    impl<St: State> State for SetBadgeType<St> {
396        type BadgeType = Set<members::badge_type>;
397        type IssuanceUri = St::IssuanceUri;
398        type Issuer = St::Issuer;
399    }
400    ///State transition - sets the `issuance_uri` field to Set
401    pub struct SetIssuanceUri<St: State = Empty>(PhantomData<fn() -> St>);
402    impl<St: State> sealed::Sealed for SetIssuanceUri<St> {}
403    impl<St: State> State for SetIssuanceUri<St> {
404        type BadgeType = St::BadgeType;
405        type IssuanceUri = Set<members::issuance_uri>;
406        type Issuer = St::Issuer;
407    }
408    ///State transition - sets the `issuer` field to Set
409    pub struct SetIssuer<St: State = Empty>(PhantomData<fn() -> St>);
410    impl<St: State> sealed::Sealed for SetIssuer<St> {}
411    impl<St: State> State for SetIssuer<St> {
412        type BadgeType = St::BadgeType;
413        type IssuanceUri = St::IssuanceUri;
414        type Issuer = Set<members::issuer>;
415    }
416    /// Marker types for field names
417    #[allow(non_camel_case_types)]
418    pub mod members {
419        ///Marker type for the `badge_type` field
420        pub struct badge_type(());
421        ///Marker type for the `issuance_uri` field
422        pub struct issuance_uri(());
423        ///Marker type for the `issuer` field
424        pub struct issuer(());
425    }
426}
427
428/// Builder for constructing an instance of this type.
429pub struct BadgeIssuanceViewBuilder<
430    St: badge_issuance_view_state::State,
431    S: BosStr = DefaultStr,
432> {
433    _state: PhantomData<fn() -> St>,
434    _fields: (
435        Option<BadgeIssuanceViewBadgeType<S>>,
436        Option<S>,
437        Option<UriValue<S>>,
438        Option<S>,
439        Option<AtUri<S>>,
440        Option<Did<S>>,
441        Option<S>,
442        Option<bool>,
443    ),
444    _type: PhantomData<fn() -> S>,
445}
446
447impl BadgeIssuanceView<DefaultStr> {
448    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
449    pub fn new() -> BadgeIssuanceViewBuilder<
450        badge_issuance_view_state::Empty,
451        DefaultStr,
452    > {
453        BadgeIssuanceViewBuilder::new()
454    }
455}
456
457impl<S: BosStr> BadgeIssuanceView<S> {
458    /// Create a new builder for this type
459    pub fn builder() -> BadgeIssuanceViewBuilder<badge_issuance_view_state::Empty, S> {
460        BadgeIssuanceViewBuilder::builder()
461    }
462}
463
464impl BadgeIssuanceViewBuilder<badge_issuance_view_state::Empty, DefaultStr> {
465    /// Create a new builder with all fields unset, using the default string type, if needed
466    pub fn new() -> Self {
467        BadgeIssuanceViewBuilder {
468            _state: PhantomData,
469            _fields: (None, None, None, None, None, None, None, None),
470            _type: PhantomData,
471        }
472    }
473}
474
475impl<S: BosStr> BadgeIssuanceViewBuilder<badge_issuance_view_state::Empty, S> {
476    /// Create a new builder with all fields unset
477    pub fn builder() -> Self {
478        BadgeIssuanceViewBuilder {
479            _state: PhantomData,
480            _fields: (None, None, None, None, None, None, None, None),
481            _type: PhantomData,
482        }
483    }
484}
485
486impl<St, S: BosStr> BadgeIssuanceViewBuilder<St, S>
487where
488    St: badge_issuance_view_state::State,
489    St::BadgeType: badge_issuance_view_state::IsUnset,
490{
491    /// Set the `badgeType` field (required)
492    pub fn badge_type(
493        mut self,
494        value: impl Into<BadgeIssuanceViewBadgeType<S>>,
495    ) -> BadgeIssuanceViewBuilder<badge_issuance_view_state::SetBadgeType<St>, S> {
496        self._fields.0 = Option::Some(value.into());
497        BadgeIssuanceViewBuilder {
498            _state: PhantomData,
499            _fields: self._fields,
500            _type: PhantomData,
501        }
502    }
503}
504
505impl<St: badge_issuance_view_state::State, S: BosStr> BadgeIssuanceViewBuilder<St, S> {
506    /// Set the `description` field (optional)
507    pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
508        self._fields.1 = value.into();
509        self
510    }
511    /// Set the `description` field to an Option value (optional)
512    pub fn maybe_description(mut self, value: Option<S>) -> Self {
513        self._fields.1 = value;
514        self
515    }
516}
517
518impl<St: badge_issuance_view_state::State, S: BosStr> BadgeIssuanceViewBuilder<St, S> {
519    /// Set the `imageUrl` field (optional)
520    pub fn image_url(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
521        self._fields.2 = value.into();
522        self
523    }
524    /// Set the `imageUrl` field to an Option value (optional)
525    pub fn maybe_image_url(mut self, value: Option<UriValue<S>>) -> Self {
526        self._fields.2 = value;
527        self
528    }
529}
530
531impl<St: badge_issuance_view_state::State, S: BosStr> BadgeIssuanceViewBuilder<St, S> {
532    /// Set the `issuanceCid` field (optional)
533    pub fn issuance_cid(mut self, value: impl Into<Option<S>>) -> Self {
534        self._fields.3 = value.into();
535        self
536    }
537    /// Set the `issuanceCid` field to an Option value (optional)
538    pub fn maybe_issuance_cid(mut self, value: Option<S>) -> Self {
539        self._fields.3 = value;
540        self
541    }
542}
543
544impl<St, S: BosStr> BadgeIssuanceViewBuilder<St, S>
545where
546    St: badge_issuance_view_state::State,
547    St::IssuanceUri: badge_issuance_view_state::IsUnset,
548{
549    /// Set the `issuanceUri` field (required)
550    pub fn issuance_uri(
551        mut self,
552        value: impl Into<AtUri<S>>,
553    ) -> BadgeIssuanceViewBuilder<badge_issuance_view_state::SetIssuanceUri<St>, S> {
554        self._fields.4 = Option::Some(value.into());
555        BadgeIssuanceViewBuilder {
556            _state: PhantomData,
557            _fields: self._fields,
558            _type: PhantomData,
559        }
560    }
561}
562
563impl<St, S: BosStr> BadgeIssuanceViewBuilder<St, S>
564where
565    St: badge_issuance_view_state::State,
566    St::Issuer: badge_issuance_view_state::IsUnset,
567{
568    /// Set the `issuer` field (required)
569    pub fn issuer(
570        mut self,
571        value: impl Into<Did<S>>,
572    ) -> BadgeIssuanceViewBuilder<badge_issuance_view_state::SetIssuer<St>, S> {
573        self._fields.5 = Option::Some(value.into());
574        BadgeIssuanceViewBuilder {
575            _state: PhantomData,
576            _fields: self._fields,
577            _type: PhantomData,
578        }
579    }
580}
581
582impl<St: badge_issuance_view_state::State, S: BosStr> BadgeIssuanceViewBuilder<St, S> {
583    /// Set the `name` field (optional)
584    pub fn name(mut self, value: impl Into<Option<S>>) -> Self {
585        self._fields.6 = value.into();
586        self
587    }
588    /// Set the `name` field to an Option value (optional)
589    pub fn maybe_name(mut self, value: Option<S>) -> Self {
590        self._fields.6 = value;
591        self
592    }
593}
594
595impl<St: badge_issuance_view_state::State, S: BosStr> BadgeIssuanceViewBuilder<St, S> {
596    /// Set the `selected` field (optional)
597    pub fn selected(mut self, value: impl Into<Option<bool>>) -> Self {
598        self._fields.7 = value.into();
599        self
600    }
601    /// Set the `selected` field to an Option value (optional)
602    pub fn maybe_selected(mut self, value: Option<bool>) -> Self {
603        self._fields.7 = value;
604        self
605    }
606}
607
608impl<St, S: BosStr> BadgeIssuanceViewBuilder<St, S>
609where
610    St: badge_issuance_view_state::State,
611    St::BadgeType: badge_issuance_view_state::IsSet,
612    St::IssuanceUri: badge_issuance_view_state::IsSet,
613    St::Issuer: badge_issuance_view_state::IsSet,
614{
615    /// Build the final struct.
616    pub fn build(self) -> BadgeIssuanceView<S> {
617        BadgeIssuanceView {
618            badge_type: self._fields.0.unwrap(),
619            description: self._fields.1,
620            image_url: self._fields.2,
621            issuance_cid: self._fields.3,
622            issuance_uri: self._fields.4.unwrap(),
623            issuer: self._fields.5.unwrap(),
624            name: self._fields.6,
625            selected: self._fields.7,
626            extra_data: Default::default(),
627        }
628    }
629    /// Build the final struct with custom extra_data.
630    pub fn build_with_data(
631        self,
632        extra_data: BTreeMap<SmolStr, Data<S>>,
633    ) -> BadgeIssuanceView<S> {
634        BadgeIssuanceView {
635            badge_type: self._fields.0.unwrap(),
636            description: self._fields.1,
637            image_url: self._fields.2,
638            issuance_cid: self._fields.3,
639            issuance_uri: self._fields.4.unwrap(),
640            issuer: self._fields.5.unwrap(),
641            name: self._fields.6,
642            selected: self._fields.7,
643            extra_data: Some(extra_data),
644        }
645    }
646}
647
648fn lexicon_doc_place_stream_badge_defs() -> LexiconDoc<'static> {
649    #[allow(unused_imports)]
650    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
651    use jacquard_lexicon::lexicon::*;
652    use alloc::collections::BTreeMap;
653    LexiconDoc {
654        lexicon: Lexicon::Lexicon1,
655        id: CowStr::new_static("place.stream.badge.defs"),
656        defs: {
657            let mut map = BTreeMap::new();
658            map.insert(
659                SmolStr::new_static("badgeIssuanceView"),
660                LexUserType::Object(LexObject {
661                    description: Some(
662                        CowStr::new_static(
663                            "A resolved view of a badge issuance, including def fields for display.",
664                        ),
665                    ),
666                    required: Some(
667                        vec![
668                            SmolStr::new_static("issuanceUri"),
669                            SmolStr::new_static("badgeType"),
670                            SmolStr::new_static("issuer")
671                        ],
672                    ),
673                    properties: {
674                        #[allow(unused_mut)]
675                        let mut map = BTreeMap::new();
676                        map.insert(
677                            SmolStr::new_static("badgeType"),
678                            LexObjectProperty::String(LexString { ..Default::default() }),
679                        );
680                        map.insert(
681                            SmolStr::new_static("description"),
682                            LexObjectProperty::String(LexString {
683                                description: Some(
684                                    CowStr::new_static("Description from the badge definition."),
685                                ),
686                                ..Default::default()
687                            }),
688                        );
689                        map.insert(
690                            SmolStr::new_static("imageUrl"),
691                            LexObjectProperty::String(LexString {
692                                description: Some(
693                                    CowStr::new_static("Resolved image URL for the badge icon."),
694                                ),
695                                format: Some(LexStringFormat::Uri),
696                                ..Default::default()
697                            }),
698                        );
699                        map.insert(
700                            SmolStr::new_static("issuanceCid"),
701                            LexObjectProperty::String(LexString {
702                                description: Some(
703                                    CowStr::new_static(
704                                        "CID of the place.stream.badge.issuance record.",
705                                    ),
706                                ),
707                                ..Default::default()
708                            }),
709                        );
710                        map.insert(
711                            SmolStr::new_static("issuanceUri"),
712                            LexObjectProperty::String(LexString {
713                                description: Some(
714                                    CowStr::new_static(
715                                        "AT URI of the place.stream.badge.issuance record.",
716                                    ),
717                                ),
718                                format: Some(LexStringFormat::AtUri),
719                                ..Default::default()
720                            }),
721                        );
722                        map.insert(
723                            SmolStr::new_static("issuer"),
724                            LexObjectProperty::String(LexString {
725                                description: Some(
726                                    CowStr::new_static("DID of the badge issuer."),
727                                ),
728                                format: Some(LexStringFormat::Did),
729                                ..Default::default()
730                            }),
731                        );
732                        map.insert(
733                            SmolStr::new_static("name"),
734                            LexObjectProperty::String(LexString {
735                                description: Some(
736                                    CowStr::new_static(
737                                        "Display name from the badge definition.",
738                                    ),
739                                ),
740                                ..Default::default()
741                            }),
742                        );
743                        map.insert(
744                            SmolStr::new_static("selected"),
745                            LexObjectProperty::Boolean(LexBoolean {
746                                ..Default::default()
747                            }),
748                        );
749                        map
750                    },
751                    ..Default::default()
752                }),
753            );
754            map.insert(
755                SmolStr::new_static("badgeSlot"),
756                LexUserType::Object(LexObject {
757                    description: Some(
758                        CowStr::new_static(
759                            "A display slot containing available issuance-based badges and which one (if any) is currently selected.",
760                        ),
761                    ),
762                    required: Some(vec![SmolStr::new_static("available")]),
763                    properties: {
764                        #[allow(unused_mut)]
765                        let mut map = BTreeMap::new();
766                        map.insert(
767                            SmolStr::new_static("available"),
768                            LexObjectProperty::Array(LexArray {
769                                description: Some(
770                                    CowStr::new_static("All badges available for this slot."),
771                                ),
772                                items: LexArrayItem::Ref(LexRef {
773                                    r#ref: CowStr::new_static("#badgeIssuanceView"),
774                                    ..Default::default()
775                                }),
776                                ..Default::default()
777                            }),
778                        );
779                        map.insert(
780                            SmolStr::new_static("selected"),
781                            LexObjectProperty::Ref(LexRef {
782                                r#ref: CowStr::new_static("#badgeIssuanceView"),
783                                ..Default::default()
784                            }),
785                        );
786                        map
787                    },
788                    ..Default::default()
789                }),
790            );
791            map.insert(
792                SmolStr::new_static("badgeView"),
793                LexUserType::Object(LexObject {
794                    description: Some(
795                        CowStr::new_static(
796                            "View of a badge record, with fields resolved for display. If the DID in issuer is not the current streamplace node, the signature field shall be required.",
797                        ),
798                    ),
799                    required: Some(
800                        vec![
801                            SmolStr::new_static("badgeType"),
802                            SmolStr::new_static("issuer"),
803                            SmolStr::new_static("recipient")
804                        ],
805                    ),
806                    properties: {
807                        #[allow(unused_mut)]
808                        let mut map = BTreeMap::new();
809                        map.insert(
810                            SmolStr::new_static("badgeType"),
811                            LexObjectProperty::String(LexString { ..Default::default() }),
812                        );
813                        map.insert(
814                            SmolStr::new_static("description"),
815                            LexObjectProperty::String(LexString {
816                                description: Some(
817                                    CowStr::new_static("Description from the badge definition."),
818                                ),
819                                ..Default::default()
820                            }),
821                        );
822                        map.insert(
823                            SmolStr::new_static("imageUrl"),
824                            LexObjectProperty::String(LexString {
825                                description: Some(
826                                    CowStr::new_static("Resolved image URL for the badge icon."),
827                                ),
828                                format: Some(LexStringFormat::Uri),
829                                ..Default::default()
830                            }),
831                        );
832                        map.insert(
833                            SmolStr::new_static("issuer"),
834                            LexObjectProperty::String(LexString {
835                                description: Some(
836                                    CowStr::new_static("DID of the badge issuer."),
837                                ),
838                                format: Some(LexStringFormat::Did),
839                                ..Default::default()
840                            }),
841                        );
842                        map.insert(
843                            SmolStr::new_static("name"),
844                            LexObjectProperty::String(LexString {
845                                description: Some(
846                                    CowStr::new_static(
847                                        "Display name from the badge definition.",
848                                    ),
849                                ),
850                                ..Default::default()
851                            }),
852                        );
853                        map.insert(
854                            SmolStr::new_static("recipient"),
855                            LexObjectProperty::String(LexString {
856                                description: Some(
857                                    CowStr::new_static("DID of the badge recipient."),
858                                ),
859                                format: Some(LexStringFormat::Did),
860                                ..Default::default()
861                            }),
862                        );
863                        map.insert(
864                            SmolStr::new_static("signature"),
865                            LexObjectProperty::String(LexString {
866                                description: Some(
867                                    CowStr::new_static(
868                                        "TODO: Cryptographic signature of the badge (of a place.stream.key).",
869                                    ),
870                                ),
871                                ..Default::default()
872                            }),
873                        );
874                        map
875                    },
876                    ..Default::default()
877                }),
878            );
879            map.insert(
880                SmolStr::new_static("bot"),
881                LexUserType::Token(LexToken { ..Default::default() }),
882            );
883            map.insert(
884                SmolStr::new_static("event"),
885                LexUserType::Token(LexToken { ..Default::default() }),
886            );
887            map.insert(
888                SmolStr::new_static("mod"),
889                LexUserType::Token(LexToken { ..Default::default() }),
890            );
891            map.insert(
892                SmolStr::new_static("streamer"),
893                LexUserType::Token(LexToken { ..Default::default() }),
894            );
895            map.insert(
896                SmolStr::new_static("vip"),
897                LexUserType::Token(LexToken { ..Default::default() }),
898            );
899            map
900        },
901        ..Default::default()
902    }
903}
904
905pub mod badge_slot_state {
906
907    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
908    #[allow(unused)]
909    use ::core::marker::PhantomData;
910    mod sealed {
911        pub trait Sealed {}
912    }
913    /// State trait tracking which required fields have been set
914    pub trait State: sealed::Sealed {
915        type Available;
916    }
917    /// Empty state - all required fields are unset
918    pub struct Empty(());
919    impl sealed::Sealed for Empty {}
920    impl State for Empty {
921        type Available = Unset;
922    }
923    ///State transition - sets the `available` field to Set
924    pub struct SetAvailable<St: State = Empty>(PhantomData<fn() -> St>);
925    impl<St: State> sealed::Sealed for SetAvailable<St> {}
926    impl<St: State> State for SetAvailable<St> {
927        type Available = Set<members::available>;
928    }
929    /// Marker types for field names
930    #[allow(non_camel_case_types)]
931    pub mod members {
932        ///Marker type for the `available` field
933        pub struct available(());
934    }
935}
936
937/// Builder for constructing an instance of this type.
938pub struct BadgeSlotBuilder<St: badge_slot_state::State, S: BosStr = DefaultStr> {
939    _state: PhantomData<fn() -> St>,
940    _fields: (
941        Option<Vec<badge::BadgeIssuanceView<S>>>,
942        Option<badge::BadgeIssuanceView<S>>,
943    ),
944    _type: PhantomData<fn() -> S>,
945}
946
947impl BadgeSlot<DefaultStr> {
948    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
949    pub fn new() -> BadgeSlotBuilder<badge_slot_state::Empty, DefaultStr> {
950        BadgeSlotBuilder::new()
951    }
952}
953
954impl<S: BosStr> BadgeSlot<S> {
955    /// Create a new builder for this type
956    pub fn builder() -> BadgeSlotBuilder<badge_slot_state::Empty, S> {
957        BadgeSlotBuilder::builder()
958    }
959}
960
961impl BadgeSlotBuilder<badge_slot_state::Empty, DefaultStr> {
962    /// Create a new builder with all fields unset, using the default string type, if needed
963    pub fn new() -> Self {
964        BadgeSlotBuilder {
965            _state: PhantomData,
966            _fields: (None, None),
967            _type: PhantomData,
968        }
969    }
970}
971
972impl<S: BosStr> BadgeSlotBuilder<badge_slot_state::Empty, S> {
973    /// Create a new builder with all fields unset
974    pub fn builder() -> Self {
975        BadgeSlotBuilder {
976            _state: PhantomData,
977            _fields: (None, None),
978            _type: PhantomData,
979        }
980    }
981}
982
983impl<St, S: BosStr> BadgeSlotBuilder<St, S>
984where
985    St: badge_slot_state::State,
986    St::Available: badge_slot_state::IsUnset,
987{
988    /// Set the `available` field (required)
989    pub fn available(
990        mut self,
991        value: impl Into<Vec<badge::BadgeIssuanceView<S>>>,
992    ) -> BadgeSlotBuilder<badge_slot_state::SetAvailable<St>, S> {
993        self._fields.0 = Option::Some(value.into());
994        BadgeSlotBuilder {
995            _state: PhantomData,
996            _fields: self._fields,
997            _type: PhantomData,
998        }
999    }
1000}
1001
1002impl<St: badge_slot_state::State, S: BosStr> BadgeSlotBuilder<St, S> {
1003    /// Set the `selected` field (optional)
1004    pub fn selected(
1005        mut self,
1006        value: impl Into<Option<badge::BadgeIssuanceView<S>>>,
1007    ) -> Self {
1008        self._fields.1 = value.into();
1009        self
1010    }
1011    /// Set the `selected` field to an Option value (optional)
1012    pub fn maybe_selected(mut self, value: Option<badge::BadgeIssuanceView<S>>) -> Self {
1013        self._fields.1 = value;
1014        self
1015    }
1016}
1017
1018impl<St, S: BosStr> BadgeSlotBuilder<St, S>
1019where
1020    St: badge_slot_state::State,
1021    St::Available: badge_slot_state::IsSet,
1022{
1023    /// Build the final struct.
1024    pub fn build(self) -> BadgeSlot<S> {
1025        BadgeSlot {
1026            available: self._fields.0.unwrap(),
1027            selected: self._fields.1,
1028            extra_data: Default::default(),
1029        }
1030    }
1031    /// Build the final struct with custom extra_data.
1032    pub fn build_with_data(
1033        self,
1034        extra_data: BTreeMap<SmolStr, Data<S>>,
1035    ) -> BadgeSlot<S> {
1036        BadgeSlot {
1037            available: self._fields.0.unwrap(),
1038            selected: self._fields.1,
1039            extra_data: Some(extra_data),
1040        }
1041    }
1042}
1043
1044pub mod badge_view_state {
1045
1046    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1047    #[allow(unused)]
1048    use ::core::marker::PhantomData;
1049    mod sealed {
1050        pub trait Sealed {}
1051    }
1052    /// State trait tracking which required fields have been set
1053    pub trait State: sealed::Sealed {
1054        type BadgeType;
1055        type Issuer;
1056        type Recipient;
1057    }
1058    /// Empty state - all required fields are unset
1059    pub struct Empty(());
1060    impl sealed::Sealed for Empty {}
1061    impl State for Empty {
1062        type BadgeType = Unset;
1063        type Issuer = Unset;
1064        type Recipient = Unset;
1065    }
1066    ///State transition - sets the `badge_type` field to Set
1067    pub struct SetBadgeType<St: State = Empty>(PhantomData<fn() -> St>);
1068    impl<St: State> sealed::Sealed for SetBadgeType<St> {}
1069    impl<St: State> State for SetBadgeType<St> {
1070        type BadgeType = Set<members::badge_type>;
1071        type Issuer = St::Issuer;
1072        type Recipient = St::Recipient;
1073    }
1074    ///State transition - sets the `issuer` field to Set
1075    pub struct SetIssuer<St: State = Empty>(PhantomData<fn() -> St>);
1076    impl<St: State> sealed::Sealed for SetIssuer<St> {}
1077    impl<St: State> State for SetIssuer<St> {
1078        type BadgeType = St::BadgeType;
1079        type Issuer = Set<members::issuer>;
1080        type Recipient = St::Recipient;
1081    }
1082    ///State transition - sets the `recipient` field to Set
1083    pub struct SetRecipient<St: State = Empty>(PhantomData<fn() -> St>);
1084    impl<St: State> sealed::Sealed for SetRecipient<St> {}
1085    impl<St: State> State for SetRecipient<St> {
1086        type BadgeType = St::BadgeType;
1087        type Issuer = St::Issuer;
1088        type Recipient = Set<members::recipient>;
1089    }
1090    /// Marker types for field names
1091    #[allow(non_camel_case_types)]
1092    pub mod members {
1093        ///Marker type for the `badge_type` field
1094        pub struct badge_type(());
1095        ///Marker type for the `issuer` field
1096        pub struct issuer(());
1097        ///Marker type for the `recipient` field
1098        pub struct recipient(());
1099    }
1100}
1101
1102/// Builder for constructing an instance of this type.
1103pub struct BadgeViewBuilder<St: badge_view_state::State, S: BosStr = DefaultStr> {
1104    _state: PhantomData<fn() -> St>,
1105    _fields: (
1106        Option<BadgeViewBadgeType<S>>,
1107        Option<S>,
1108        Option<UriValue<S>>,
1109        Option<Did<S>>,
1110        Option<S>,
1111        Option<Did<S>>,
1112        Option<S>,
1113    ),
1114    _type: PhantomData<fn() -> S>,
1115}
1116
1117impl BadgeView<DefaultStr> {
1118    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
1119    pub fn new() -> BadgeViewBuilder<badge_view_state::Empty, DefaultStr> {
1120        BadgeViewBuilder::new()
1121    }
1122}
1123
1124impl<S: BosStr> BadgeView<S> {
1125    /// Create a new builder for this type
1126    pub fn builder() -> BadgeViewBuilder<badge_view_state::Empty, S> {
1127        BadgeViewBuilder::builder()
1128    }
1129}
1130
1131impl BadgeViewBuilder<badge_view_state::Empty, DefaultStr> {
1132    /// Create a new builder with all fields unset, using the default string type, if needed
1133    pub fn new() -> Self {
1134        BadgeViewBuilder {
1135            _state: PhantomData,
1136            _fields: (None, None, None, None, None, None, None),
1137            _type: PhantomData,
1138        }
1139    }
1140}
1141
1142impl<S: BosStr> BadgeViewBuilder<badge_view_state::Empty, S> {
1143    /// Create a new builder with all fields unset
1144    pub fn builder() -> Self {
1145        BadgeViewBuilder {
1146            _state: PhantomData,
1147            _fields: (None, None, None, None, None, None, None),
1148            _type: PhantomData,
1149        }
1150    }
1151}
1152
1153impl<St, S: BosStr> BadgeViewBuilder<St, S>
1154where
1155    St: badge_view_state::State,
1156    St::BadgeType: badge_view_state::IsUnset,
1157{
1158    /// Set the `badgeType` field (required)
1159    pub fn badge_type(
1160        mut self,
1161        value: impl Into<BadgeViewBadgeType<S>>,
1162    ) -> BadgeViewBuilder<badge_view_state::SetBadgeType<St>, S> {
1163        self._fields.0 = Option::Some(value.into());
1164        BadgeViewBuilder {
1165            _state: PhantomData,
1166            _fields: self._fields,
1167            _type: PhantomData,
1168        }
1169    }
1170}
1171
1172impl<St: badge_view_state::State, S: BosStr> BadgeViewBuilder<St, S> {
1173    /// Set the `description` field (optional)
1174    pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
1175        self._fields.1 = value.into();
1176        self
1177    }
1178    /// Set the `description` field to an Option value (optional)
1179    pub fn maybe_description(mut self, value: Option<S>) -> Self {
1180        self._fields.1 = value;
1181        self
1182    }
1183}
1184
1185impl<St: badge_view_state::State, S: BosStr> BadgeViewBuilder<St, S> {
1186    /// Set the `imageUrl` field (optional)
1187    pub fn image_url(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
1188        self._fields.2 = value.into();
1189        self
1190    }
1191    /// Set the `imageUrl` field to an Option value (optional)
1192    pub fn maybe_image_url(mut self, value: Option<UriValue<S>>) -> Self {
1193        self._fields.2 = value;
1194        self
1195    }
1196}
1197
1198impl<St, S: BosStr> BadgeViewBuilder<St, S>
1199where
1200    St: badge_view_state::State,
1201    St::Issuer: badge_view_state::IsUnset,
1202{
1203    /// Set the `issuer` field (required)
1204    pub fn issuer(
1205        mut self,
1206        value: impl Into<Did<S>>,
1207    ) -> BadgeViewBuilder<badge_view_state::SetIssuer<St>, S> {
1208        self._fields.3 = Option::Some(value.into());
1209        BadgeViewBuilder {
1210            _state: PhantomData,
1211            _fields: self._fields,
1212            _type: PhantomData,
1213        }
1214    }
1215}
1216
1217impl<St: badge_view_state::State, S: BosStr> BadgeViewBuilder<St, S> {
1218    /// Set the `name` field (optional)
1219    pub fn name(mut self, value: impl Into<Option<S>>) -> Self {
1220        self._fields.4 = value.into();
1221        self
1222    }
1223    /// Set the `name` field to an Option value (optional)
1224    pub fn maybe_name(mut self, value: Option<S>) -> Self {
1225        self._fields.4 = value;
1226        self
1227    }
1228}
1229
1230impl<St, S: BosStr> BadgeViewBuilder<St, S>
1231where
1232    St: badge_view_state::State,
1233    St::Recipient: badge_view_state::IsUnset,
1234{
1235    /// Set the `recipient` field (required)
1236    pub fn recipient(
1237        mut self,
1238        value: impl Into<Did<S>>,
1239    ) -> BadgeViewBuilder<badge_view_state::SetRecipient<St>, S> {
1240        self._fields.5 = Option::Some(value.into());
1241        BadgeViewBuilder {
1242            _state: PhantomData,
1243            _fields: self._fields,
1244            _type: PhantomData,
1245        }
1246    }
1247}
1248
1249impl<St: badge_view_state::State, S: BosStr> BadgeViewBuilder<St, S> {
1250    /// Set the `signature` field (optional)
1251    pub fn signature(mut self, value: impl Into<Option<S>>) -> Self {
1252        self._fields.6 = value.into();
1253        self
1254    }
1255    /// Set the `signature` field to an Option value (optional)
1256    pub fn maybe_signature(mut self, value: Option<S>) -> Self {
1257        self._fields.6 = value;
1258        self
1259    }
1260}
1261
1262impl<St, S: BosStr> BadgeViewBuilder<St, S>
1263where
1264    St: badge_view_state::State,
1265    St::BadgeType: badge_view_state::IsSet,
1266    St::Issuer: badge_view_state::IsSet,
1267    St::Recipient: badge_view_state::IsSet,
1268{
1269    /// Build the final struct.
1270    pub fn build(self) -> BadgeView<S> {
1271        BadgeView {
1272            badge_type: self._fields.0.unwrap(),
1273            description: self._fields.1,
1274            image_url: self._fields.2,
1275            issuer: self._fields.3.unwrap(),
1276            name: self._fields.4,
1277            recipient: self._fields.5.unwrap(),
1278            signature: self._fields.6,
1279            extra_data: Default::default(),
1280        }
1281    }
1282    /// Build the final struct with custom extra_data.
1283    pub fn build_with_data(
1284        self,
1285        extra_data: BTreeMap<SmolStr, Data<S>>,
1286    ) -> BadgeView<S> {
1287        BadgeView {
1288            badge_type: self._fields.0.unwrap(),
1289            description: self._fields.1,
1290            image_url: self._fields.2,
1291            issuer: self._fields.3.unwrap(),
1292            name: self._fields.4,
1293            recipient: self._fields.5.unwrap(),
1294            signature: self._fields.6,
1295            extra_data: Some(extra_data),
1296        }
1297    }
1298}