#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Group<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub description: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub genres: std::option::Option<Vec<crate::media_ionosphere::Genre<'a>>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub icon: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
#[serde(borrow)]
pub ionosphere: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub keywords: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub kind: std::option::Option<GroupKind<'a>>,
pub language: jacquard_common::types::string::Language,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub member_of: std::option::Option<Vec<crate::media_ionosphere::Membership<'a>>>,
#[serde(borrow)]
pub name: jacquard_common::CowStr<'a>,
}
pub mod group_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type Language;
type Ionosphere;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Language = Unset;
type Ionosphere = Unset;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type Language = S::Language;
type Ionosphere = S::Ionosphere;
}
pub struct SetLanguage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLanguage<S> {}
impl<S: State> State for SetLanguage<S> {
type Name = S::Name;
type Language = Set<members::language>;
type Ionosphere = S::Ionosphere;
}
pub struct SetIonosphere<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIonosphere<S> {}
impl<S: State> State for SetIonosphere<S> {
type Name = S::Name;
type Language = S::Language;
type Ionosphere = Set<members::ionosphere>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct language(());
pub struct ionosphere(());
}
}
pub struct GroupBuilder<'a, S: group_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<Vec<crate::media_ionosphere::Genre<'a>>>,
::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
::core::option::Option<GroupKind<'a>>,
::core::option::Option<jacquard_common::types::string::Language>,
::core::option::Option<Vec<crate::media_ionosphere::Membership<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Group<'a> {
pub fn new() -> GroupBuilder<'a, group_state::Empty> {
GroupBuilder::new()
}
}
impl<'a> GroupBuilder<'a, group_state::Empty> {
pub fn new() -> Self {
GroupBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: group_state::State> GroupBuilder<'a, S> {
pub fn description(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_description(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S: group_state::State> GroupBuilder<'a, S> {
pub fn genres(
mut self,
value: impl Into<Option<Vec<crate::media_ionosphere::Genre<'a>>>>,
) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_genres(
mut self,
value: Option<Vec<crate::media_ionosphere::Genre<'a>>>,
) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S: group_state::State> GroupBuilder<'a, S> {
pub fn icon(
mut self,
value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_icon(
mut self,
value: Option<jacquard_common::types::blob::BlobRef<'a>>,
) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S> GroupBuilder<'a, S>
where
S: group_state::State,
S::Ionosphere: group_state::IsUnset,
{
pub fn ionosphere(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> GroupBuilder<'a, group_state::SetIonosphere<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
GroupBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: group_state::State> GroupBuilder<'a, S> {
pub fn keywords(
mut self,
value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>,
) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_keywords(
mut self,
value: Option<Vec<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S: group_state::State> GroupBuilder<'a, S> {
pub fn kind(mut self, value: impl Into<Option<GroupKind<'a>>>) -> Self {
self.__unsafe_private_named.5 = value.into();
self
}
pub fn maybe_kind(mut self, value: Option<GroupKind<'a>>) -> Self {
self.__unsafe_private_named.5 = value;
self
}
}
impl<'a, S> GroupBuilder<'a, S>
where
S: group_state::State,
S::Language: group_state::IsUnset,
{
pub fn language(
mut self,
value: impl Into<jacquard_common::types::string::Language>,
) -> GroupBuilder<'a, group_state::SetLanguage<S>> {
self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
GroupBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: group_state::State> GroupBuilder<'a, S> {
pub fn member_of(
mut self,
value: impl Into<Option<Vec<crate::media_ionosphere::Membership<'a>>>>,
) -> Self {
self.__unsafe_private_named.7 = value.into();
self
}
pub fn maybe_member_of(
mut self,
value: Option<Vec<crate::media_ionosphere::Membership<'a>>>,
) -> Self {
self.__unsafe_private_named.7 = value;
self
}
}
impl<'a, S> GroupBuilder<'a, S>
where
S: group_state::State,
S::Name: group_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> GroupBuilder<'a, group_state::SetName<S>> {
self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into());
GroupBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> GroupBuilder<'a, S>
where
S: group_state::State,
S::Name: group_state::IsSet,
S::Language: group_state::IsSet,
S::Ionosphere: group_state::IsSet,
{
pub fn build(self) -> Group<'a> {
Group {
description: self.__unsafe_private_named.0,
genres: self.__unsafe_private_named.1,
icon: self.__unsafe_private_named.2,
ionosphere: self.__unsafe_private_named.3.unwrap(),
keywords: self.__unsafe_private_named.4,
kind: self.__unsafe_private_named.5,
language: self.__unsafe_private_named.6.unwrap(),
member_of: self.__unsafe_private_named.7,
name: self.__unsafe_private_named.8.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Group<'a> {
Group {
description: self.__unsafe_private_named.0,
genres: self.__unsafe_private_named.1,
icon: self.__unsafe_private_named.2,
ionosphere: self.__unsafe_private_named.3.unwrap(),
keywords: self.__unsafe_private_named.4,
kind: self.__unsafe_private_named.5,
language: self.__unsafe_private_named.6.unwrap(),
member_of: self.__unsafe_private_named.7,
name: self.__unsafe_private_named.8.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> Group<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, GroupRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GroupKind<'a> {
Series,
Show,
Concept,
Magazine,
Topic,
OtherCollection,
OtherChoice,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> GroupKind<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Series => "series",
Self::Show => "show",
Self::Concept => "concept",
Self::Magazine => "magazine",
Self::Topic => "topic",
Self::OtherCollection => "otherCollection",
Self::OtherChoice => "otherChoice",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for GroupKind<'a> {
fn from(s: &'a str) -> Self {
match s {
"series" => Self::Series,
"show" => Self::Show,
"concept" => Self::Concept,
"magazine" => Self::Magazine,
"topic" => Self::Topic,
"otherCollection" => Self::OtherCollection,
"otherChoice" => Self::OtherChoice,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for GroupKind<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"series" => Self::Series,
"show" => Self::Show,
"concept" => Self::Concept,
"magazine" => Self::Magazine,
"topic" => Self::Topic,
"otherCollection" => Self::OtherCollection,
"otherChoice" => Self::OtherChoice,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for GroupKind<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for GroupKind<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for GroupKind<'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 GroupKind<'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 GroupKind<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for GroupKind<'_> {
type Output = GroupKind<'static>;
fn into_static(self) -> Self::Output {
match self {
GroupKind::Series => GroupKind::Series,
GroupKind::Show => GroupKind::Show,
GroupKind::Concept => GroupKind::Concept,
GroupKind::Magazine => GroupKind::Magazine,
GroupKind::Topic => GroupKind::Topic,
GroupKind::OtherCollection => GroupKind::OtherCollection,
GroupKind::OtherChoice => GroupKind::OtherChoice,
GroupKind::Other(v) => GroupKind::Other(v.into_static()),
}
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct GroupGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Group<'a>,
}
impl From<GroupGetRecordOutput<'_>> for Group<'_> {
fn from(output: GroupGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Group<'_> {
const NSID: &'static str = "media.ionosphere.group";
type Record = GroupRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct GroupRecord;
impl jacquard_common::xrpc::XrpcResp for GroupRecord {
const NSID: &'static str = "media.ionosphere.group";
const ENCODING: &'static str = "application/json";
type Output<'de> = GroupGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for GroupRecord {
const NSID: &'static str = "media.ionosphere.group";
type Record = GroupRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Group<'a> {
fn nsid() -> &'static str {
"media.ionosphere.group"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_media_ionosphere_group()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"description",
),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.icon {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/*"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobMimeTypeNotAccepted {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"icon",
),
accepted: vec!["image/*".to_string()],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.ionosphere;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"ionosphere",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.kind {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"kind",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
{
let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes(
value.as_ref(),
true,
)
.count();
if count > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"name",
),
max: 128usize,
actual: count,
});
}
}
}
Ok(())
}
}
fn lexicon_doc_media_ionosphere_group() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("media.ionosphere.group"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"Represents a grouping of subgroups or programmes",
),
),
key: Some(::jacquard_common::CowStr::new_static("any")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("ionosphere"),
::jacquard_common::deps::smol_str::SmolStr::new_static("name"),
::jacquard_common::deps::smol_str::SmolStr::new_static("language")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"description",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(512usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"genres",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"media.ionosphere.defs#genre",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"icon",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
description: None,
accept: None,
max_size: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"ionosphere",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static("Version identifier"),
),
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"keywords",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"kind",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Type of group, see Table 30 of DAB SPI for idea",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"language",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The language of the string values in this record. NOT the language of the content",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Language,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"memberOf",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: Some(
::jacquard_common::CowStr::new_static(
"A list of groups this record is a member of",
),
),
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"media.ionosphere.defs#membership",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"name",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: Some(128usize),
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}