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

#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
/// All rights reserved to the creator — others cannot use, modify, or share without explicit authorization.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct AllRightsReserved;
impl core::fmt::Display for AllRightsReserved {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "all-rights-reserved")
    }
}

/// Attribution + non-commercial + no derivatives. Others may download and share your work with credit, but cannot change it or use it commercially.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct CcByNcNd40;
impl core::fmt::Display for CcByNcNd40 {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "cc-by-nc-nd_4__0")
    }
}

/// Attribution + non-commercial + share-alike. Others may adapt and build upon your work for non-commercial purposes only, must credit you, and must license their new creations under identical terms.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct CcByNcSa40;
impl core::fmt::Display for CcByNcSa40 {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "cc-by-nc-sa_4__0")
    }
}

/// Attribution + non-commercial. Others may adapt and build upon your work for non-commercial purposes only, and must credit you.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct CcByNc40;
impl core::fmt::Display for CcByNc40 {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "cc-by-nc_4__0")
    }
}

/// Attribution + no derivatives. Others may reuse your work, even commercially, but it must remain unchanged and you must be credited.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct CcByNd40;
impl core::fmt::Display for CcByNd40 {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "cc-by-nd_4__0")
    }
}

/// Attribution + share-alike. Others may adapt and build upon your work, even commercially, if they credit you and license their new creations under identical terms.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct CcBySa40;
impl core::fmt::Display for CcBySa40 {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "cc-by-sa_4__0")
    }
}

/// Attribution required. Others may copy, distribute, remix, and build upon your work, even commercially, if they credit you.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct CcBy40;
impl core::fmt::Display for CcBy40 {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "cc-by_4__0")
    }
}

/// Public domain dedication. You waive all copyright and related rights where possible. Others may copy, modify, distribute, or perform your work for any purpose without attribution.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Cc010;
impl core::fmt::Display for Cc010 {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "cc0_1__0")
    }
}

/// Content rights and attribution information.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ContentRights<S: BosStr = DefaultStr> {
    ///Copyright notice for the work.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub copyright_notice: Option<S>,
    ///Year of creation or publication.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub copyright_year: Option<i64>,
    ///Name of the creator of the work.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub creator: Option<S>,
    ///Credit line for the work.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credit_line: Option<S>,
    ///License URL or identifier.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub license: Option<ContentRightsLicense<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// License URL or identifier.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ContentRightsLicense<S: BosStr = DefaultStr> {
    AllRightsReserved,
    Cc010,
    CcBy40,
    CcBySa40,
    CcByNc40,
    CcByNcSa40,
    CcByNd40,
    CcByNcNd40,
    Other(S),
}

impl<S: BosStr> ContentRightsLicense<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::AllRightsReserved => {
                "place.stream.metadata.contentRights#all-rights-reserved"
            }
            Self::Cc010 => "place.stream.metadata.contentRights#cc0_1__0",
            Self::CcBy40 => "place.stream.metadata.contentRights#cc-by_4__0",
            Self::CcBySa40 => "place.stream.metadata.contentRights#cc-by-sa_4__0",
            Self::CcByNc40 => "place.stream.metadata.contentRights#cc-by-nc_4__0",
            Self::CcByNcSa40 => "place.stream.metadata.contentRights#cc-by-nc-sa_4__0",
            Self::CcByNd40 => "place.stream.metadata.contentRights#cc-by-nd_4__0",
            Self::CcByNcNd40 => "place.stream.metadata.contentRights#cc-by-nc-nd_4__0",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "place.stream.metadata.contentRights#all-rights-reserved" => {
                Self::AllRightsReserved
            }
            "place.stream.metadata.contentRights#cc0_1__0" => Self::Cc010,
            "place.stream.metadata.contentRights#cc-by_4__0" => Self::CcBy40,
            "place.stream.metadata.contentRights#cc-by-sa_4__0" => Self::CcBySa40,
            "place.stream.metadata.contentRights#cc-by-nc_4__0" => Self::CcByNc40,
            "place.stream.metadata.contentRights#cc-by-nc-sa_4__0" => Self::CcByNcSa40,
            "place.stream.metadata.contentRights#cc-by-nd_4__0" => Self::CcByNd40,
            "place.stream.metadata.contentRights#cc-by-nc-nd_4__0" => Self::CcByNcNd40,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for ContentRightsLicense<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for ContentRightsLicense<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for ContentRightsLicense<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for ContentRightsLicense<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ContentRightsLicense<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ContentRightsLicense::AllRightsReserved => {
                ContentRightsLicense::AllRightsReserved
            }
            ContentRightsLicense::Cc010 => ContentRightsLicense::Cc010,
            ContentRightsLicense::CcBy40 => ContentRightsLicense::CcBy40,
            ContentRightsLicense::CcBySa40 => ContentRightsLicense::CcBySa40,
            ContentRightsLicense::CcByNc40 => ContentRightsLicense::CcByNc40,
            ContentRightsLicense::CcByNcSa40 => ContentRightsLicense::CcByNcSa40,
            ContentRightsLicense::CcByNd40 => ContentRightsLicense::CcByNd40,
            ContentRightsLicense::CcByNcNd40 => ContentRightsLicense::CcByNcNd40,
            ContentRightsLicense::Other(v) => {
                ContentRightsLicense::Other(v.into_static())
            }
        }
    }
}

impl<S: BosStr> LexiconSchema for ContentRights<S> {
    fn nsid() -> &'static str {
        "place.stream.metadata.contentRights"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_place_stream_metadata_contentRights()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_place_stream_metadata_contentRights() -> 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("place.stream.metadata.contentRights"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("all-rights-reserved"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("cc-by-nc-nd_4__0"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("cc-by-nc-sa_4__0"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("cc-by-nc_4__0"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("cc-by-nd_4__0"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("cc-by-sa_4__0"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("cc-by_4__0"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("cc0_1__0"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Content rights and attribution information."),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("copyrightNotice"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Copyright notice for the work."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("copyrightYear"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("creator"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Name of the creator of the work."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("creditLine"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Credit line for the work."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("license"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("License URL or identifier."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}