#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
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::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, Language, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::org_atpodcasting::PodcastRef;
use crate::org_atpodcasting::episode;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ChaptersRef<S: BosStr = DefaultStr> {
pub mime_type: S,
pub url: UriValue<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "org.atpodcasting.episode",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Episode<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alternate_media: Option<Vec<episode::MediaRef<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub artwork: Option<BlobRef<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub chapters: Option<episode::ChaptersRef<S>>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub duration: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub episode_number: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub episode_type: Option<EpisodeEpisodeType<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub explicit: Option<bool>,
pub feed_item_guid: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub link: Option<UriValue<S>>,
pub media: episode::MediaRef<S>,
pub podcast: PodcastRef<S>,
pub published_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub season_number: Option<i64>,
pub title: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub transcript: Option<Vec<episode::TranscriptRef<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 EpisodeEpisodeType<S: BosStr = DefaultStr> {
Full,
Trailer,
Bonus,
Other(S),
}
impl<S: BosStr> EpisodeEpisodeType<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Full => "full",
Self::Trailer => "trailer",
Self::Bonus => "bonus",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"full" => Self::Full,
"trailer" => Self::Trailer,
"bonus" => Self::Bonus,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for EpisodeEpisodeType<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for EpisodeEpisodeType<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for EpisodeEpisodeType<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 EpisodeEpisodeType<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 EpisodeEpisodeType<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for EpisodeEpisodeType<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = EpisodeEpisodeType<S::Output>;
fn into_static(self) -> Self::Output {
match self {
EpisodeEpisodeType::Full => EpisodeEpisodeType::Full,
EpisodeEpisodeType::Trailer => EpisodeEpisodeType::Trailer,
EpisodeEpisodeType::Bonus => EpisodeEpisodeType::Bonus,
EpisodeEpisodeType::Other(v) => EpisodeEpisodeType::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct EpisodeGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Episode<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct MediaRef<S: BosStr = DefaultStr> {
pub mime_type: S,
pub url: UriValue<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct TranscriptRef<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<Language>,
pub mime_type: S,
pub url: UriValue<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Episode<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, EpisodeRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for ChaptersRef<S> {
fn nsid() -> &'static str {
"org.atpodcasting.episode"
}
fn def_name() -> &'static str {
"chaptersRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_atpodcasting_episode()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct EpisodeRecord;
impl XrpcResp for EpisodeRecord {
const NSID: &'static str = "org.atpodcasting.episode";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = EpisodeGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<EpisodeGetRecordOutput<S>> for Episode<S> {
fn from(output: EpisodeGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Episode<S> {
const NSID: &'static str = "org.atpodcasting.episode";
type Record = EpisodeRecord;
}
impl Collection for EpisodeRecord {
const NSID: &'static str = "org.atpodcasting.episode";
type Record = EpisodeRecord;
}
impl<S: BosStr> LexiconSchema for Episode<S> {
fn nsid() -> &'static str {
"org.atpodcasting.episode"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_atpodcasting_episode()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.alternate_media {
#[allow(unused_comparisons)]
if value.len() > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("alternate_media"),
max: 10usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.artwork {
{
let size = value.blob().size;
if size > 5000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("artwork"),
max: 5000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.artwork {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg"];
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(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("artwork"),
accepted: vec!["image/png".to_string(), "image/jpeg".to_string()],
actual: mime.to_string(),
});
}
}
}
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.duration;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("duration"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.episode_number {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("episode_number"),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.feed_item_guid;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("feed_item_guid"),
max: 2000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.season_number {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("season_number"),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 500usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.transcript {
#[allow(unused_comparisons)]
if value.len() > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("transcript"),
max: 10usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for MediaRef<S> {
fn nsid() -> &'static str {
"org.atpodcasting.episode"
}
fn def_name() -> &'static str {
"mediaRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_atpodcasting_episode()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for TranscriptRef<S> {
fn nsid() -> &'static str {
"org.atpodcasting.episode"
}
fn def_name() -> &'static str {
"transcriptRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_atpodcasting_episode()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod chapters_ref_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Url;
type MimeType;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Url = Unset;
type MimeType = Unset;
}
pub struct SetUrl<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUrl<St> {}
impl<St: State> State for SetUrl<St> {
type Url = Set<members::url>;
type MimeType = St::MimeType;
}
pub struct SetMimeType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMimeType<St> {}
impl<St: State> State for SetMimeType<St> {
type Url = St::Url;
type MimeType = Set<members::mime_type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct url(());
pub struct mime_type(());
}
}
pub struct ChaptersRefBuilder<S: BosStr, St: chapters_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<UriValue<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ChaptersRef<S> {
pub fn new() -> ChaptersRefBuilder<S, chapters_ref_state::Empty> {
ChaptersRefBuilder::new()
}
}
impl<S: BosStr> ChaptersRefBuilder<S, chapters_ref_state::Empty> {
pub fn new() -> Self {
ChaptersRefBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ChaptersRefBuilder<S, St>
where
St: chapters_ref_state::State,
St::MimeType: chapters_ref_state::IsUnset,
{
pub fn mime_type(
mut self,
value: impl Into<S>,
) -> ChaptersRefBuilder<S, chapters_ref_state::SetMimeType<St>> {
self._fields.0 = Option::Some(value.into());
ChaptersRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ChaptersRefBuilder<S, St>
where
St: chapters_ref_state::State,
St::Url: chapters_ref_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<S>>,
) -> ChaptersRefBuilder<S, chapters_ref_state::SetUrl<St>> {
self._fields.1 = Option::Some(value.into());
ChaptersRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ChaptersRefBuilder<S, St>
where
St: chapters_ref_state::State,
St::Url: chapters_ref_state::IsSet,
St::MimeType: chapters_ref_state::IsSet,
{
pub fn build(self) -> ChaptersRef<S> {
ChaptersRef {
mime_type: self._fields.0.unwrap(),
url: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ChaptersRef<S> {
ChaptersRef {
mime_type: self._fields.0.unwrap(),
url: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_atpodcasting_episode() -> 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("org.atpodcasting.episode"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("chaptersRef"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Reference to an externally hosted chapters file.",
),
),
required: Some(
vec![SmolStr::new_static("url"), SmolStr::new_static("mimeType")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("mimeType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"MIME type of the chapters file (e.g. application/json+chapters).",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URL of the chapters file."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A podcast episode. Record key is a UUIDv5 derived from the podcast GUID (as namespace) and the episode's feedItemGuid (as name), enabling deterministic lookup from RSS feed metadata.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("podcast"),
SmolStr::new_static("title"), SmolStr::new_static("media"),
SmolStr::new_static("publishedAt"),
SmolStr::new_static("duration"),
SmolStr::new_static("feedItemGuid"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alternateMedia"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Alternate versions of the episode media (e.g. different formats or audio-only versions of video episodes).",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#mediaRef"),
..Default::default()
}),
max_length: Some(10usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artwork"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("chapters"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#chaptersRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the episode record was created."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"A description or show notes for the episode.",
),
),
max_length: Some(10000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("duration"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("episodeNumber"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("episodeType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The type of episode. Defaults to full."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("explicit"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("feedItemGuid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The original feed item identifier. Must match the <guid> element of the corresponding RSS feed item. The record key (rkey) is derived from this value as uuid5(<podcast:guid>, feedItemGuid).",
),
),
max_length: Some(2000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("link"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"URL of a companion webpage or show notes page for the episode.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("media"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#mediaRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("podcast"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"org.atpodcasting.defs#podcastRef",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("publishedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the episode was published."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seasonNumber"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The title of the episode."),
),
max_length: Some(500usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("transcript"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"References to externally hosted transcript files (e.g. VTT, SRT, JSON). Multiple entries allow providing transcripts in different formats.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#transcriptRef"),
..Default::default()
}),
max_length: Some(10usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mediaRef"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Reference to an externally hosted media file.",
)),
required: Some(vec![
SmolStr::new_static("url"),
SmolStr::new_static("mimeType"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("mimeType"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"MIME type of the media file (e.g. audio/mpeg, video/mp4).",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("URL of the media file.")),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("transcriptRef"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Reference to an externally hosted transcript file.",
),
),
required: Some(
vec![SmolStr::new_static("url"), SmolStr::new_static("mimeType")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("language"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Language of the transcript (ISO 639-1 two-letter code, e.g. 'en', 'es', 'pt').",
),
),
format: Some(LexStringFormat::Language),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mimeType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"MIME type of the transcript file (e.g. text/vtt, application/x-subrip, application/json).",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URL of the transcript file."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod episode_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Media;
type Podcast;
type Title;
type PublishedAt;
type FeedItemGuid;
type Duration;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Media = Unset;
type Podcast = Unset;
type Title = Unset;
type PublishedAt = Unset;
type FeedItemGuid = Unset;
type Duration = Unset;
type CreatedAt = Unset;
}
pub struct SetMedia<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMedia<St> {}
impl<St: State> State for SetMedia<St> {
type Media = Set<members::media>;
type Podcast = St::Podcast;
type Title = St::Title;
type PublishedAt = St::PublishedAt;
type FeedItemGuid = St::FeedItemGuid;
type Duration = St::Duration;
type CreatedAt = St::CreatedAt;
}
pub struct SetPodcast<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPodcast<St> {}
impl<St: State> State for SetPodcast<St> {
type Media = St::Media;
type Podcast = Set<members::podcast>;
type Title = St::Title;
type PublishedAt = St::PublishedAt;
type FeedItemGuid = St::FeedItemGuid;
type Duration = St::Duration;
type CreatedAt = St::CreatedAt;
}
pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTitle<St> {}
impl<St: State> State for SetTitle<St> {
type Media = St::Media;
type Podcast = St::Podcast;
type Title = Set<members::title>;
type PublishedAt = St::PublishedAt;
type FeedItemGuid = St::FeedItemGuid;
type Duration = St::Duration;
type CreatedAt = St::CreatedAt;
}
pub struct SetPublishedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPublishedAt<St> {}
impl<St: State> State for SetPublishedAt<St> {
type Media = St::Media;
type Podcast = St::Podcast;
type Title = St::Title;
type PublishedAt = Set<members::published_at>;
type FeedItemGuid = St::FeedItemGuid;
type Duration = St::Duration;
type CreatedAt = St::CreatedAt;
}
pub struct SetFeedItemGuid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetFeedItemGuid<St> {}
impl<St: State> State for SetFeedItemGuid<St> {
type Media = St::Media;
type Podcast = St::Podcast;
type Title = St::Title;
type PublishedAt = St::PublishedAt;
type FeedItemGuid = Set<members::feed_item_guid>;
type Duration = St::Duration;
type CreatedAt = St::CreatedAt;
}
pub struct SetDuration<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDuration<St> {}
impl<St: State> State for SetDuration<St> {
type Media = St::Media;
type Podcast = St::Podcast;
type Title = St::Title;
type PublishedAt = St::PublishedAt;
type FeedItemGuid = St::FeedItemGuid;
type Duration = Set<members::duration>;
type CreatedAt = St::CreatedAt;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type Media = St::Media;
type Podcast = St::Podcast;
type Title = St::Title;
type PublishedAt = St::PublishedAt;
type FeedItemGuid = St::FeedItemGuid;
type Duration = St::Duration;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct media(());
pub struct podcast(());
pub struct title(());
pub struct published_at(());
pub struct feed_item_guid(());
pub struct duration(());
pub struct created_at(());
}
}
pub struct EpisodeBuilder<S: BosStr, St: episode_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<episode::MediaRef<S>>>,
Option<BlobRef<S>>,
Option<episode::ChaptersRef<S>>,
Option<Datetime>,
Option<S>,
Option<i64>,
Option<i64>,
Option<EpisodeEpisodeType<S>>,
Option<bool>,
Option<S>,
Option<UriValue<S>>,
Option<episode::MediaRef<S>>,
Option<PodcastRef<S>>,
Option<Datetime>,
Option<i64>,
Option<S>,
Option<Vec<episode::TranscriptRef<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Episode<S> {
pub fn new() -> EpisodeBuilder<S, episode_state::Empty> {
EpisodeBuilder::new()
}
}
impl<S: BosStr> EpisodeBuilder<S, episode_state::Empty> {
pub fn new() -> Self {
EpisodeBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn alternate_media(mut self, value: impl Into<Option<Vec<episode::MediaRef<S>>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alternate_media(mut self, value: Option<Vec<episode::MediaRef<S>>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn artwork(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_artwork(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn chapters(mut self, value: impl Into<Option<episode::ChaptersRef<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_chapters(mut self, value: Option<episode::ChaptersRef<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::CreatedAt: episode_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> EpisodeBuilder<S, episode_state::SetCreatedAt<St>> {
self._fields.3 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::Duration: episode_state::IsUnset,
{
pub fn duration(
mut self,
value: impl Into<i64>,
) -> EpisodeBuilder<S, episode_state::SetDuration<St>> {
self._fields.5 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn episode_number(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_episode_number(mut self, value: Option<i64>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn episode_type(mut self, value: impl Into<Option<EpisodeEpisodeType<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_episode_type(mut self, value: Option<EpisodeEpisodeType<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn explicit(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_explicit(mut self, value: Option<bool>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::FeedItemGuid: episode_state::IsUnset,
{
pub fn feed_item_guid(
mut self,
value: impl Into<S>,
) -> EpisodeBuilder<S, episode_state::SetFeedItemGuid<St>> {
self._fields.9 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn link(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_link(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::Media: episode_state::IsUnset,
{
pub fn media(
mut self,
value: impl Into<episode::MediaRef<S>>,
) -> EpisodeBuilder<S, episode_state::SetMedia<St>> {
self._fields.11 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::Podcast: episode_state::IsUnset,
{
pub fn podcast(
mut self,
value: impl Into<PodcastRef<S>>,
) -> EpisodeBuilder<S, episode_state::SetPodcast<St>> {
self._fields.12 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::PublishedAt: episode_state::IsUnset,
{
pub fn published_at(
mut self,
value: impl Into<Datetime>,
) -> EpisodeBuilder<S, episode_state::SetPublishedAt<St>> {
self._fields.13 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn season_number(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.14 = value.into();
self
}
pub fn maybe_season_number(mut self, value: Option<i64>) -> Self {
self._fields.14 = value;
self
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::Title: episode_state::IsUnset,
{
pub fn title(mut self, value: impl Into<S>) -> EpisodeBuilder<S, episode_state::SetTitle<St>> {
self._fields.15 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: episode_state::State> EpisodeBuilder<S, St> {
pub fn transcript(mut self, value: impl Into<Option<Vec<episode::TranscriptRef<S>>>>) -> Self {
self._fields.16 = value.into();
self
}
pub fn maybe_transcript(mut self, value: Option<Vec<episode::TranscriptRef<S>>>) -> Self {
self._fields.16 = value;
self
}
}
impl<S: BosStr, St> EpisodeBuilder<S, St>
where
St: episode_state::State,
St::Media: episode_state::IsSet,
St::Podcast: episode_state::IsSet,
St::Title: episode_state::IsSet,
St::PublishedAt: episode_state::IsSet,
St::FeedItemGuid: episode_state::IsSet,
St::Duration: episode_state::IsSet,
St::CreatedAt: episode_state::IsSet,
{
pub fn build(self) -> Episode<S> {
Episode {
alternate_media: self._fields.0,
artwork: self._fields.1,
chapters: self._fields.2,
created_at: self._fields.3.unwrap(),
description: self._fields.4,
duration: self._fields.5.unwrap(),
episode_number: self._fields.6,
episode_type: self._fields.7,
explicit: self._fields.8,
feed_item_guid: self._fields.9.unwrap(),
link: self._fields.10,
media: self._fields.11.unwrap(),
podcast: self._fields.12.unwrap(),
published_at: self._fields.13.unwrap(),
season_number: self._fields.14,
title: self._fields.15.unwrap(),
transcript: self._fields.16,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Episode<S> {
Episode {
alternate_media: self._fields.0,
artwork: self._fields.1,
chapters: self._fields.2,
created_at: self._fields.3.unwrap(),
description: self._fields.4,
duration: self._fields.5.unwrap(),
episode_number: self._fields.6,
episode_type: self._fields.7,
explicit: self._fields.8,
feed_item_guid: self._fields.9.unwrap(),
link: self._fields.10,
media: self._fields.11.unwrap(),
podcast: self._fields.12.unwrap(),
published_at: self._fields.13.unwrap(),
season_number: self._fields.14,
title: self._fields.15.unwrap(),
transcript: self._fields.16,
extra_data: Some(extra_data),
}
}
}
pub mod media_ref_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Url;
type MimeType;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Url = Unset;
type MimeType = Unset;
}
pub struct SetUrl<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUrl<St> {}
impl<St: State> State for SetUrl<St> {
type Url = Set<members::url>;
type MimeType = St::MimeType;
}
pub struct SetMimeType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMimeType<St> {}
impl<St: State> State for SetMimeType<St> {
type Url = St::Url;
type MimeType = Set<members::mime_type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct url(());
pub struct mime_type(());
}
}
pub struct MediaRefBuilder<S: BosStr, St: media_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<UriValue<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> MediaRef<S> {
pub fn new() -> MediaRefBuilder<S, media_ref_state::Empty> {
MediaRefBuilder::new()
}
}
impl<S: BosStr> MediaRefBuilder<S, media_ref_state::Empty> {
pub fn new() -> Self {
MediaRefBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MediaRefBuilder<S, St>
where
St: media_ref_state::State,
St::MimeType: media_ref_state::IsUnset,
{
pub fn mime_type(
mut self,
value: impl Into<S>,
) -> MediaRefBuilder<S, media_ref_state::SetMimeType<St>> {
self._fields.0 = Option::Some(value.into());
MediaRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MediaRefBuilder<S, St>
where
St: media_ref_state::State,
St::Url: media_ref_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<S>>,
) -> MediaRefBuilder<S, media_ref_state::SetUrl<St>> {
self._fields.1 = Option::Some(value.into());
MediaRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MediaRefBuilder<S, St>
where
St: media_ref_state::State,
St::Url: media_ref_state::IsSet,
St::MimeType: media_ref_state::IsSet,
{
pub fn build(self) -> MediaRef<S> {
MediaRef {
mime_type: self._fields.0.unwrap(),
url: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> MediaRef<S> {
MediaRef {
mime_type: self._fields.0.unwrap(),
url: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod transcript_ref_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type MimeType;
type Url;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type MimeType = Unset;
type Url = Unset;
}
pub struct SetMimeType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMimeType<St> {}
impl<St: State> State for SetMimeType<St> {
type MimeType = Set<members::mime_type>;
type Url = St::Url;
}
pub struct SetUrl<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUrl<St> {}
impl<St: State> State for SetUrl<St> {
type MimeType = St::MimeType;
type Url = Set<members::url>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct mime_type(());
pub struct url(());
}
}
pub struct TranscriptRefBuilder<S: BosStr, St: transcript_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Language>, Option<S>, Option<UriValue<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> TranscriptRef<S> {
pub fn new() -> TranscriptRefBuilder<S, transcript_ref_state::Empty> {
TranscriptRefBuilder::new()
}
}
impl<S: BosStr> TranscriptRefBuilder<S, transcript_ref_state::Empty> {
pub fn new() -> Self {
TranscriptRefBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: transcript_ref_state::State> TranscriptRefBuilder<S, St> {
pub fn language(mut self, value: impl Into<Option<Language>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_language(mut self, value: Option<Language>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> TranscriptRefBuilder<S, St>
where
St: transcript_ref_state::State,
St::MimeType: transcript_ref_state::IsUnset,
{
pub fn mime_type(
mut self,
value: impl Into<S>,
) -> TranscriptRefBuilder<S, transcript_ref_state::SetMimeType<St>> {
self._fields.1 = Option::Some(value.into());
TranscriptRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TranscriptRefBuilder<S, St>
where
St: transcript_ref_state::State,
St::Url: transcript_ref_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<S>>,
) -> TranscriptRefBuilder<S, transcript_ref_state::SetUrl<St>> {
self._fields.2 = Option::Some(value.into());
TranscriptRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TranscriptRefBuilder<S, St>
where
St: transcript_ref_state::State,
St::MimeType: transcript_ref_state::IsSet,
St::Url: transcript_ref_state::IsSet,
{
pub fn build(self) -> TranscriptRef<S> {
TranscriptRef {
language: self._fields.0,
mime_type: self._fields.1.unwrap(),
url: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> TranscriptRef<S> {
TranscriptRef {
language: self._fields.0,
mime_type: self._fields.1.unwrap(),
url: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}