#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use jacquard_common::{BosStr, CowStr, 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::{Deserialize, Serialize};
#[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")
}
}
#[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> {
#[serde(skip_serializing_if = "Option::is_none")]
pub copyright_notice: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub copyright_year: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub creator: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub credit_line: Option<S>,
#[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>>>,
}
#[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(),
}
}
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> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
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()
}
}