use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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};
#[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")
}
}
#[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")
}
}
#[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")
}
}
#[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")
}
}
#[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")
}
}
#[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")
}
}
#[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")
}
}
#[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")
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ContentRights<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub copyright_notice: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub copyright_year: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub creator: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub credit_line: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub license: Option<ContentRightsLicense<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ContentRightsLicense<'a> {
AllRightsReserved,
Cc010,
CcBy40,
CcBySa40,
CcByNc40,
CcByNcSa40,
CcByNd40,
CcByNcNd40,
Other(CowStr<'a>),
}
impl<'a> ContentRightsLicense<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for ContentRightsLicense<'a> {
fn from(s: &'a str) -> Self {
match s {
"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(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ContentRightsLicense<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"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(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ContentRightsLicense<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ContentRightsLicense<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ContentRightsLicense<'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 ContentRightsLicense<'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 ContentRightsLicense<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ContentRightsLicense<'_> {
type Output = ContentRightsLicense<'static>;
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<'a> LexiconSchema for ContentRights<'a> {
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()
}
}