// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: media.ionosphere.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

pub mod group;
pub mod log;
pub mod programme;
pub mod service;


#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Datetime, UriValue};
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::media_ionosphere;
/// BearerURI as specified in ETSI TS 103 270
pub type Bearer<'a> = UriValue<'a>;
/// Represents the method of accessing a broadcast; i.e. live

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Broadcast<'a> {
    #[serde(borrow)]
    pub bearer: media_ionosphere::Bearer<'a>,
    ///When used in a list, this can be used to sort the attempted connections or preferred methods  Defaults to `0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_broadcast_cost")]
    pub cost: Option<i64>,
    ///The datetime from which this method is available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub from: Option<Datetime>,
    ///Offset in milliseconds compared to other bearers  Defaults to `0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_broadcast_offset")]
    pub offset: Option<i64>,
    ///The datetime where this method is no longer available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub until: Option<Datetime>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Credit<'a> {
    #[serde(borrow)]
    pub entity: media_ionosphere::Entity<'a>,
    ///Self-explanatory, but beware that the expected values may change in future (possibly to match TV-Anytime role classification schema)
    #[serde(borrow)]
    pub role: CreditRole<'a>,
}

/// Self-explanatory, but beware that the expected values may change in future (possibly to match TV-Anytime role classification schema)

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CreditRole<'a> {
    Creator,
    Contributor,
    Guest,
    Other(CowStr<'a>),
}

impl<'a> CreditRole<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Creator => "creator",
            Self::Contributor => "contributor",
            Self::Guest => "guest",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for CreditRole<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "creator" => Self::Creator,
            "contributor" => Self::Contributor,
            "guest" => Self::Guest,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for CreditRole<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "creator" => Self::Creator,
            "contributor" => Self::Contributor,
            "guest" => Self::Guest,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> core::fmt::Display for CreditRole<'a> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<'a> AsRef<str> for CreditRole<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> serde::Serialize for CreditRole<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for CreditRole<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for CreditRole<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for CreditRole<'_> {
    type Output = CreditRole<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            CreditRole::Creator => CreditRole::Creator,
            CreditRole::Contributor => CreditRole::Contributor,
            CreditRole::Guest => CreditRole::Guest,
            CreditRole::Other(v) => CreditRole::Other(v.into_static()),
        }
    }
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Entity<'a> {
    #[serde(borrow)]
    pub name: CowStr<'a>,
    #[serde(borrow)]
    pub r#type: CowStr<'a>,
}

/// TV-Anytime classification scheme URIs permitted by ETSI TS 102 818 section 5.3
pub type Genre<'a> = UriValue<'a>;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Geocoordinates<'a> {
    #[serde(borrow)]
    pub latitude: CowStr<'a>,
    #[serde(borrow)]
    pub longitude: CowStr<'a>,
}

/// Represents membership to a group, optionally with an index

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Membership<'a> {
    #[serde(borrow)]
    pub group: AtUri<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub index: Option<i64>,
}

/// Represents the method of accessing a recording

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Recording<'a> {
    #[serde(borrow)]
    pub bearer: media_ionosphere::Bearer<'a>,
    ///When used in a list, this can be used to sort the attempted connections or preferred methods  Defaults to `0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_recording_cost")]
    pub cost: Option<i64>,
    ///The datetime from which this method is available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub from: Option<Datetime>,
    ///The datetime where this method is no longer available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub until: Option<Datetime>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Track<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub album: Option<CowStr<'a>>,
    ///Artists in order of importance to the track
    #[serde(borrow)]
    pub artists: Vec<CowStr<'a>>,
    #[serde(borrow)]
    pub title: CowStr<'a>,
}

impl<'a> LexiconSchema for Broadcast<'a> {
    fn nsid() -> &'static str {
        "media.ionosphere.defs"
    }
    fn def_name() -> &'static str {
        "broadcast"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_media_ionosphere_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for Credit<'a> {
    fn nsid() -> &'static str {
        "media.ionosphere.defs"
    }
    fn def_name() -> &'static str {
        "credit"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_media_ionosphere_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.role;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("role"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Entity<'a> {
    fn nsid() -> &'static str {
        "media.ionosphere.defs"
    }
    fn def_name() -> &'static str {
        "entity"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_media_ionosphere_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("name"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.r#type;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("type"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Geocoordinates<'a> {
    fn nsid() -> &'static str {
        "media.ionosphere.defs"
    }
    fn def_name() -> &'static str {
        "geocoordinates"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_media_ionosphere_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.latitude;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("latitude"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.longitude;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("longitude"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Membership<'a> {
    fn nsid() -> &'static str {
        "media.ionosphere.defs"
    }
    fn def_name() -> &'static str {
        "membership"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_media_ionosphere_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for Recording<'a> {
    fn nsid() -> &'static str {
        "media.ionosphere.defs"
    }
    fn def_name() -> &'static str {
        "recording"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_media_ionosphere_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for Track<'a> {
    fn nsid() -> &'static str {
        "media.ionosphere.defs"
    }
    fn def_name() -> &'static str {
        "track"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_media_ionosphere_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.album {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("album"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("title"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

fn _default_broadcast_cost() -> Option<i64> {
    Some(0i64)
}

fn _default_broadcast_offset() -> Option<i64> {
    Some(0i64)
}

pub mod broadcast_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Bearer;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Bearer = Unset;
    }
    ///State transition - sets the `bearer` field to Set
    pub struct SetBearer<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBearer<S> {}
    impl<S: State> State for SetBearer<S> {
        type Bearer = Set<members::bearer>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `bearer` field
        pub struct bearer(());
    }
}

/// Builder for constructing an instance of this type
pub struct BroadcastBuilder<'a, S: broadcast_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<media_ionosphere::Bearer<'a>>,
        Option<i64>,
        Option<Datetime>,
        Option<i64>,
        Option<Datetime>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Broadcast<'a> {
    /// Create a new builder for this type
    pub fn new() -> BroadcastBuilder<'a, broadcast_state::Empty> {
        BroadcastBuilder::new()
    }
}

impl<'a> BroadcastBuilder<'a, broadcast_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        BroadcastBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> BroadcastBuilder<'a, S>
where
    S: broadcast_state::State,
    S::Bearer: broadcast_state::IsUnset,
{
    /// Set the `bearer` field (required)
    pub fn bearer(
        mut self,
        value: impl Into<media_ionosphere::Bearer<'a>>,
    ) -> BroadcastBuilder<'a, broadcast_state::SetBearer<S>> {
        self._fields.0 = Option::Some(value.into());
        BroadcastBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: broadcast_state::State> BroadcastBuilder<'a, S> {
    /// Set the `cost` field (optional)
    pub fn cost(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `cost` field to an Option value (optional)
    pub fn maybe_cost(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: broadcast_state::State> BroadcastBuilder<'a, S> {
    /// Set the `from` field (optional)
    pub fn from(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `from` field to an Option value (optional)
    pub fn maybe_from(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: broadcast_state::State> BroadcastBuilder<'a, S> {
    /// Set the `offset` field (optional)
    pub fn offset(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `offset` field to an Option value (optional)
    pub fn maybe_offset(mut self, value: Option<i64>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: broadcast_state::State> BroadcastBuilder<'a, S> {
    /// Set the `until` field (optional)
    pub fn until(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `until` field to an Option value (optional)
    pub fn maybe_until(mut self, value: Option<Datetime>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> BroadcastBuilder<'a, S>
where
    S: broadcast_state::State,
    S::Bearer: broadcast_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Broadcast<'a> {
        Broadcast {
            bearer: self._fields.0.unwrap(),
            cost: self._fields.1.or_else(|| Some(0i64)),
            from: self._fields.2,
            offset: self._fields.3.or_else(|| Some(0i64)),
            until: self._fields.4,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Broadcast<'a> {
        Broadcast {
            bearer: self._fields.0.unwrap(),
            cost: self._fields.1.or_else(|| Some(0i64)),
            from: self._fields.2,
            offset: self._fields.3.or_else(|| Some(0i64)),
            until: self._fields.4,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_media_ionosphere_defs() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("media.ionosphere.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("bearer"),
                LexUserType::String(LexString {
                    description: Some(
                        CowStr::new_static("BearerURI as specified in ETSI TS 103 270"),
                    ),
                    format: Some(LexStringFormat::Uri),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("broadcast"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Represents the method of accessing a broadcast; i.e. live",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("bearer")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("bearer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("media.ionosphere.defs#bearer"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cost"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("from"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The datetime from which this method is available",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("offset"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("until"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The datetime where this method is no longer available",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("credit"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("entity"), SmolStr::new_static("role")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("entity"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("media.ionosphere.defs#entity"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("role"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Self-explanatory, but beware that the expected values may change in future (possibly to match TV-Anytime role classification schema)",
                                    ),
                                ),
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("entity"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("type"), SmolStr::new_static("name")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("genre"),
                LexUserType::String(LexString {
                    description: Some(
                        CowStr::new_static(
                            "TV-Anytime classification scheme URIs permitted by ETSI TS 102 818 section 5.3",
                        ),
                    ),
                    format: Some(LexStringFormat::Uri),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("geocoordinates"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("latitude"),
                            SmolStr::new_static("longitude")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("latitude"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("longitude"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("membership"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Represents membership to a group, optionally with an index",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("group")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("group"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("index"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("recording"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Represents the method of accessing a recording",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("bearer")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("bearer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("media.ionosphere.defs#bearer"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cost"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("from"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The datetime from which this method is available",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("until"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The datetime where this method is no longer available",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("track"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("title"), SmolStr::new_static("artists")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("album"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("artists"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Artists in order of importance to the track",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    max_length: Some(256usize),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("title"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod credit_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Entity;
        type Role;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Entity = Unset;
        type Role = Unset;
    }
    ///State transition - sets the `entity` field to Set
    pub struct SetEntity<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetEntity<S> {}
    impl<S: State> State for SetEntity<S> {
        type Entity = Set<members::entity>;
        type Role = S::Role;
    }
    ///State transition - sets the `role` field to Set
    pub struct SetRole<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRole<S> {}
    impl<S: State> State for SetRole<S> {
        type Entity = S::Entity;
        type Role = Set<members::role>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `entity` field
        pub struct entity(());
        ///Marker type for the `role` field
        pub struct role(());
    }
}

/// Builder for constructing an instance of this type
pub struct CreditBuilder<'a, S: credit_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<media_ionosphere::Entity<'a>>, Option<CreditRole<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Credit<'a> {
    /// Create a new builder for this type
    pub fn new() -> CreditBuilder<'a, credit_state::Empty> {
        CreditBuilder::new()
    }
}

impl<'a> CreditBuilder<'a, credit_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        CreditBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CreditBuilder<'a, S>
where
    S: credit_state::State,
    S::Entity: credit_state::IsUnset,
{
    /// Set the `entity` field (required)
    pub fn entity(
        mut self,
        value: impl Into<media_ionosphere::Entity<'a>>,
    ) -> CreditBuilder<'a, credit_state::SetEntity<S>> {
        self._fields.0 = Option::Some(value.into());
        CreditBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CreditBuilder<'a, S>
where
    S: credit_state::State,
    S::Role: credit_state::IsUnset,
{
    /// Set the `role` field (required)
    pub fn role(
        mut self,
        value: impl Into<CreditRole<'a>>,
    ) -> CreditBuilder<'a, credit_state::SetRole<S>> {
        self._fields.1 = Option::Some(value.into());
        CreditBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CreditBuilder<'a, S>
where
    S: credit_state::State,
    S::Entity: credit_state::IsSet,
    S::Role: credit_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Credit<'a> {
        Credit {
            entity: self._fields.0.unwrap(),
            role: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Credit<'a> {
        Credit {
            entity: self._fields.0.unwrap(),
            role: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod membership_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Group;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Group = Unset;
    }
    ///State transition - sets the `group` field to Set
    pub struct SetGroup<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetGroup<S> {}
    impl<S: State> State for SetGroup<S> {
        type Group = Set<members::group>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `group` field
        pub struct group(());
    }
}

/// Builder for constructing an instance of this type
pub struct MembershipBuilder<'a, S: membership_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<AtUri<'a>>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Membership<'a> {
    /// Create a new builder for this type
    pub fn new() -> MembershipBuilder<'a, membership_state::Empty> {
        MembershipBuilder::new()
    }
}

impl<'a> MembershipBuilder<'a, membership_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        MembershipBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> MembershipBuilder<'a, S>
where
    S: membership_state::State,
    S::Group: membership_state::IsUnset,
{
    /// Set the `group` field (required)
    pub fn group(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> MembershipBuilder<'a, membership_state::SetGroup<S>> {
        self._fields.0 = Option::Some(value.into());
        MembershipBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: membership_state::State> MembershipBuilder<'a, S> {
    /// Set the `index` field (optional)
    pub fn index(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `index` field to an Option value (optional)
    pub fn maybe_index(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> MembershipBuilder<'a, S>
where
    S: membership_state::State,
    S::Group: membership_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Membership<'a> {
        Membership {
            group: self._fields.0.unwrap(),
            index: self._fields.1,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Membership<'a> {
        Membership {
            group: self._fields.0.unwrap(),
            index: self._fields.1,
            extra_data: Some(extra_data),
        }
    }
}

fn _default_recording_cost() -> Option<i64> {
    Some(0i64)
}

pub mod recording_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Bearer;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Bearer = Unset;
    }
    ///State transition - sets the `bearer` field to Set
    pub struct SetBearer<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBearer<S> {}
    impl<S: State> State for SetBearer<S> {
        type Bearer = Set<members::bearer>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `bearer` field
        pub struct bearer(());
    }
}

/// Builder for constructing an instance of this type
pub struct RecordingBuilder<'a, S: recording_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<media_ionosphere::Bearer<'a>>,
        Option<i64>,
        Option<Datetime>,
        Option<Datetime>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Recording<'a> {
    /// Create a new builder for this type
    pub fn new() -> RecordingBuilder<'a, recording_state::Empty> {
        RecordingBuilder::new()
    }
}

impl<'a> RecordingBuilder<'a, recording_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        RecordingBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RecordingBuilder<'a, S>
where
    S: recording_state::State,
    S::Bearer: recording_state::IsUnset,
{
    /// Set the `bearer` field (required)
    pub fn bearer(
        mut self,
        value: impl Into<media_ionosphere::Bearer<'a>>,
    ) -> RecordingBuilder<'a, recording_state::SetBearer<S>> {
        self._fields.0 = Option::Some(value.into());
        RecordingBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: recording_state::State> RecordingBuilder<'a, S> {
    /// Set the `cost` field (optional)
    pub fn cost(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `cost` field to an Option value (optional)
    pub fn maybe_cost(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: recording_state::State> RecordingBuilder<'a, S> {
    /// Set the `from` field (optional)
    pub fn from(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `from` field to an Option value (optional)
    pub fn maybe_from(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: recording_state::State> RecordingBuilder<'a, S> {
    /// Set the `until` field (optional)
    pub fn until(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `until` field to an Option value (optional)
    pub fn maybe_until(mut self, value: Option<Datetime>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S> RecordingBuilder<'a, S>
where
    S: recording_state::State,
    S::Bearer: recording_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Recording<'a> {
        Recording {
            bearer: self._fields.0.unwrap(),
            cost: self._fields.1.or_else(|| Some(0i64)),
            from: self._fields.2,
            until: self._fields.3,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Recording<'a> {
        Recording {
            bearer: self._fields.0.unwrap(),
            cost: self._fields.1.or_else(|| Some(0i64)),
            from: self._fields.2,
            until: self._fields.3,
            extra_data: Some(extra_data),
        }
    }
}

pub mod track_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Title;
        type Artists;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Title = Unset;
        type Artists = Unset;
    }
    ///State transition - sets the `title` field to Set
    pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTitle<S> {}
    impl<S: State> State for SetTitle<S> {
        type Title = Set<members::title>;
        type Artists = S::Artists;
    }
    ///State transition - sets the `artists` field to Set
    pub struct SetArtists<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetArtists<S> {}
    impl<S: State> State for SetArtists<S> {
        type Title = S::Title;
        type Artists = Set<members::artists>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `title` field
        pub struct title(());
        ///Marker type for the `artists` field
        pub struct artists(());
    }
}

/// Builder for constructing an instance of this type
pub struct TrackBuilder<'a, S: track_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<Vec<CowStr<'a>>>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Track<'a> {
    /// Create a new builder for this type
    pub fn new() -> TrackBuilder<'a, track_state::Empty> {
        TrackBuilder::new()
    }
}

impl<'a> TrackBuilder<'a, track_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        TrackBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: track_state::State> TrackBuilder<'a, S> {
    /// Set the `album` field (optional)
    pub fn album(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `album` field to an Option value (optional)
    pub fn maybe_album(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> TrackBuilder<'a, S>
where
    S: track_state::State,
    S::Artists: track_state::IsUnset,
{
    /// Set the `artists` field (required)
    pub fn artists(
        mut self,
        value: impl Into<Vec<CowStr<'a>>>,
    ) -> TrackBuilder<'a, track_state::SetArtists<S>> {
        self._fields.1 = Option::Some(value.into());
        TrackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TrackBuilder<'a, S>
where
    S: track_state::State,
    S::Title: track_state::IsUnset,
{
    /// Set the `title` field (required)
    pub fn title(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> TrackBuilder<'a, track_state::SetTitle<S>> {
        self._fields.2 = Option::Some(value.into());
        TrackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TrackBuilder<'a, S>
where
    S: track_state::State,
    S::Title: track_state::IsSet,
    S::Artists: track_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Track<'a> {
        Track {
            album: self._fields.0,
            artists: self._fields.1.unwrap(),
            title: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Track<'a> {
        Track {
            album: self._fields.0,
            artists: self._fields.1.unwrap(),
            title: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}