#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::xrpc::XrpcResp;
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};
use crate::org_atpodcasting::PodcastRef;
use crate::org_atpodcasting::episode;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ChaptersRef<'a> {
#[serde(borrow)]
pub mime_type: CowStr<'a>,
#[serde(borrow)]
pub url: UriValue<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", rename = "org.atpodcasting.episode", tag = "$type")]
pub struct Episode<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub alternate_media: Option<Vec<episode::MediaRef<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub artwork: Option<BlobRef<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub chapters: Option<episode::ChaptersRef<'a>>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
pub duration: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub episode_number: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub episode_type: Option<EpisodeEpisodeType<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub explicit: Option<bool>,
#[serde(borrow)]
pub feed_item_guid: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub link: Option<UriValue<'a>>,
#[serde(borrow)]
pub media: episode::MediaRef<'a>,
#[serde(borrow)]
pub podcast: PodcastRef<'a>,
pub published_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub season_number: Option<i64>,
#[serde(borrow)]
pub title: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub transcript: Option<Vec<episode::TranscriptRef<'a>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EpisodeEpisodeType<'a> {
Full,
Trailer,
Bonus,
Other(CowStr<'a>),
}
impl<'a> EpisodeEpisodeType<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Full => "full",
Self::Trailer => "trailer",
Self::Bonus => "bonus",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for EpisodeEpisodeType<'a> {
fn from(s: &'a str) -> Self {
match s {
"full" => Self::Full,
"trailer" => Self::Trailer,
"bonus" => Self::Bonus,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for EpisodeEpisodeType<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"full" => Self::Full,
"trailer" => Self::Trailer,
"bonus" => Self::Bonus,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for EpisodeEpisodeType<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for EpisodeEpisodeType<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for EpisodeEpisodeType<'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 EpisodeEpisodeType<'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 EpisodeEpisodeType<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for EpisodeEpisodeType<'_> {
type Output = EpisodeEpisodeType<'static>;
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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Episode<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MediaRef<'a> {
#[serde(borrow)]
pub mime_type: CowStr<'a>,
#[serde(borrow)]
pub url: UriValue<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TranscriptRef<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<Language>,
#[serde(borrow)]
pub mime_type: CowStr<'a>,
#[serde(borrow)]
pub url: UriValue<'a>,
}
impl<'a> Episode<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, EpisodeRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for ChaptersRef<'a> {
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<'de> = EpisodeGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<EpisodeGetRecordOutput<'_>> for Episode<'_> {
fn from(output: EpisodeGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Episode<'_> {
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<'a> LexiconSchema for Episode<'a> {
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<'a> LexiconSchema for MediaRef<'a> {
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<'a> LexiconSchema for TranscriptRef<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMimeType<S> {}
impl<S: State> State for SetMimeType<S> {
type MimeType = Set<members::mime_type>;
type Url = S::Url;
}
pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUrl<S> {}
impl<S: State> State for SetUrl<S> {
type MimeType = S::MimeType;
type Url = Set<members::url>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct mime_type(());
pub struct url(());
}
}
pub struct ChaptersRefBuilder<'a, S: chapters_ref_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<UriValue<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ChaptersRef<'a> {
pub fn new() -> ChaptersRefBuilder<'a, chapters_ref_state::Empty> {
ChaptersRefBuilder::new()
}
}
impl<'a> ChaptersRefBuilder<'a, chapters_ref_state::Empty> {
pub fn new() -> Self {
ChaptersRefBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ChaptersRefBuilder<'a, S>
where
S: chapters_ref_state::State,
S::MimeType: chapters_ref_state::IsUnset,
{
pub fn mime_type(
mut self,
value: impl Into<CowStr<'a>>,
) -> ChaptersRefBuilder<'a, chapters_ref_state::SetMimeType<S>> {
self._fields.0 = Option::Some(value.into());
ChaptersRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ChaptersRefBuilder<'a, S>
where
S: chapters_ref_state::State,
S::Url: chapters_ref_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<'a>>,
) -> ChaptersRefBuilder<'a, chapters_ref_state::SetUrl<S>> {
self._fields.1 = Option::Some(value.into());
ChaptersRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ChaptersRefBuilder<'a, S>
where
S: chapters_ref_state::State,
S::MimeType: chapters_ref_state::IsSet,
S::Url: chapters_ref_state::IsSet,
{
pub fn build(self) -> ChaptersRef<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ChaptersRef<'a> {
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> {
#[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("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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Media;
type Podcast;
type Duration;
type Title;
type FeedItemGuid;
type CreatedAt;
type PublishedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Media = Unset;
type Podcast = Unset;
type Duration = Unset;
type Title = Unset;
type FeedItemGuid = Unset;
type CreatedAt = Unset;
type PublishedAt = Unset;
}
pub struct SetMedia<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMedia<S> {}
impl<S: State> State for SetMedia<S> {
type Media = Set<members::media>;
type Podcast = S::Podcast;
type Duration = S::Duration;
type Title = S::Title;
type FeedItemGuid = S::FeedItemGuid;
type CreatedAt = S::CreatedAt;
type PublishedAt = S::PublishedAt;
}
pub struct SetPodcast<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPodcast<S> {}
impl<S: State> State for SetPodcast<S> {
type Media = S::Media;
type Podcast = Set<members::podcast>;
type Duration = S::Duration;
type Title = S::Title;
type FeedItemGuid = S::FeedItemGuid;
type CreatedAt = S::CreatedAt;
type PublishedAt = S::PublishedAt;
}
pub struct SetDuration<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDuration<S> {}
impl<S: State> State for SetDuration<S> {
type Media = S::Media;
type Podcast = S::Podcast;
type Duration = Set<members::duration>;
type Title = S::Title;
type FeedItemGuid = S::FeedItemGuid;
type CreatedAt = S::CreatedAt;
type PublishedAt = S::PublishedAt;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type Media = S::Media;
type Podcast = S::Podcast;
type Duration = S::Duration;
type Title = Set<members::title>;
type FeedItemGuid = S::FeedItemGuid;
type CreatedAt = S::CreatedAt;
type PublishedAt = S::PublishedAt;
}
pub struct SetFeedItemGuid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetFeedItemGuid<S> {}
impl<S: State> State for SetFeedItemGuid<S> {
type Media = S::Media;
type Podcast = S::Podcast;
type Duration = S::Duration;
type Title = S::Title;
type FeedItemGuid = Set<members::feed_item_guid>;
type CreatedAt = S::CreatedAt;
type PublishedAt = S::PublishedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Media = S::Media;
type Podcast = S::Podcast;
type Duration = S::Duration;
type Title = S::Title;
type FeedItemGuid = S::FeedItemGuid;
type CreatedAt = Set<members::created_at>;
type PublishedAt = S::PublishedAt;
}
pub struct SetPublishedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPublishedAt<S> {}
impl<S: State> State for SetPublishedAt<S> {
type Media = S::Media;
type Podcast = S::Podcast;
type Duration = S::Duration;
type Title = S::Title;
type FeedItemGuid = S::FeedItemGuid;
type CreatedAt = S::CreatedAt;
type PublishedAt = Set<members::published_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct media(());
pub struct podcast(());
pub struct duration(());
pub struct title(());
pub struct feed_item_guid(());
pub struct created_at(());
pub struct published_at(());
}
}
pub struct EpisodeBuilder<'a, S: episode_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Vec<episode::MediaRef<'a>>>,
Option<BlobRef<'a>>,
Option<episode::ChaptersRef<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<i64>,
Option<i64>,
Option<EpisodeEpisodeType<'a>>,
Option<bool>,
Option<CowStr<'a>>,
Option<UriValue<'a>>,
Option<episode::MediaRef<'a>>,
Option<PodcastRef<'a>>,
Option<Datetime>,
Option<i64>,
Option<CowStr<'a>>,
Option<Vec<episode::TranscriptRef<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Episode<'a> {
pub fn new() -> EpisodeBuilder<'a, episode_state::Empty> {
EpisodeBuilder::new()
}
}
impl<'a> EpisodeBuilder<'a, 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,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
pub fn alternate_media(
mut self,
value: impl Into<Option<Vec<episode::MediaRef<'a>>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alternate_media(
mut self,
value: Option<Vec<episode::MediaRef<'a>>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
pub fn artwork(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_artwork(mut self, value: Option<BlobRef<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
pub fn chapters(
mut self,
value: impl Into<Option<episode::ChaptersRef<'a>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_chapters(mut self, value: Option<episode::ChaptersRef<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::CreatedAt: episode_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> EpisodeBuilder<'a, episode_state::SetCreatedAt<S>> {
self._fields.3 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::Duration: episode_state::IsUnset,
{
pub fn duration(
mut self,
value: impl Into<i64>,
) -> EpisodeBuilder<'a, episode_state::SetDuration<S>> {
self._fields.5 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
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<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
pub fn episode_type(
mut self,
value: impl Into<Option<EpisodeEpisodeType<'a>>>,
) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_episode_type(mut self, value: Option<EpisodeEpisodeType<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
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<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::FeedItemGuid: episode_state::IsUnset,
{
pub fn feed_item_guid(
mut self,
value: impl Into<CowStr<'a>>,
) -> EpisodeBuilder<'a, episode_state::SetFeedItemGuid<S>> {
self._fields.9 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
pub fn link(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_link(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::Media: episode_state::IsUnset,
{
pub fn media(
mut self,
value: impl Into<episode::MediaRef<'a>>,
) -> EpisodeBuilder<'a, episode_state::SetMedia<S>> {
self._fields.11 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::Podcast: episode_state::IsUnset,
{
pub fn podcast(
mut self,
value: impl Into<PodcastRef<'a>>,
) -> EpisodeBuilder<'a, episode_state::SetPodcast<S>> {
self._fields.12 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::PublishedAt: episode_state::IsUnset,
{
pub fn published_at(
mut self,
value: impl Into<Datetime>,
) -> EpisodeBuilder<'a, episode_state::SetPublishedAt<S>> {
self._fields.13 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
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<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::Title: episode_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> EpisodeBuilder<'a, episode_state::SetTitle<S>> {
self._fields.15 = Option::Some(value.into());
EpisodeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: episode_state::State> EpisodeBuilder<'a, S> {
pub fn transcript(
mut self,
value: impl Into<Option<Vec<episode::TranscriptRef<'a>>>>,
) -> Self {
self._fields.16 = value.into();
self
}
pub fn maybe_transcript(
mut self,
value: Option<Vec<episode::TranscriptRef<'a>>>,
) -> Self {
self._fields.16 = value;
self
}
}
impl<'a, S> EpisodeBuilder<'a, S>
where
S: episode_state::State,
S::Media: episode_state::IsSet,
S::Podcast: episode_state::IsSet,
S::Duration: episode_state::IsSet,
S::Title: episode_state::IsSet,
S::FeedItemGuid: episode_state::IsSet,
S::CreatedAt: episode_state::IsSet,
S::PublishedAt: episode_state::IsSet,
{
pub fn build(self) -> Episode<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Episode<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUrl<S> {}
impl<S: State> State for SetUrl<S> {
type Url = Set<members::url>;
type MimeType = S::MimeType;
}
pub struct SetMimeType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMimeType<S> {}
impl<S: State> State for SetMimeType<S> {
type Url = S::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<'a, S: media_ref_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<UriValue<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> MediaRef<'a> {
pub fn new() -> MediaRefBuilder<'a, media_ref_state::Empty> {
MediaRefBuilder::new()
}
}
impl<'a> MediaRefBuilder<'a, media_ref_state::Empty> {
pub fn new() -> Self {
MediaRefBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> MediaRefBuilder<'a, S>
where
S: media_ref_state::State,
S::MimeType: media_ref_state::IsUnset,
{
pub fn mime_type(
mut self,
value: impl Into<CowStr<'a>>,
) -> MediaRefBuilder<'a, media_ref_state::SetMimeType<S>> {
self._fields.0 = Option::Some(value.into());
MediaRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MediaRefBuilder<'a, S>
where
S: media_ref_state::State,
S::Url: media_ref_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<'a>>,
) -> MediaRefBuilder<'a, media_ref_state::SetUrl<S>> {
self._fields.1 = Option::Some(value.into());
MediaRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MediaRefBuilder<'a, S>
where
S: media_ref_state::State,
S::Url: media_ref_state::IsSet,
S::MimeType: media_ref_state::IsSet,
{
pub fn build(self) -> MediaRef<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> MediaRef<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMimeType<S> {}
impl<S: State> State for SetMimeType<S> {
type MimeType = Set<members::mime_type>;
type Url = S::Url;
}
pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUrl<S> {}
impl<S: State> State for SetUrl<S> {
type MimeType = S::MimeType;
type Url = Set<members::url>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct mime_type(());
pub struct url(());
}
}
pub struct TranscriptRefBuilder<'a, S: transcript_ref_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Language>, Option<CowStr<'a>>, Option<UriValue<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> TranscriptRef<'a> {
pub fn new() -> TranscriptRefBuilder<'a, transcript_ref_state::Empty> {
TranscriptRefBuilder::new()
}
}
impl<'a> TranscriptRefBuilder<'a, transcript_ref_state::Empty> {
pub fn new() -> Self {
TranscriptRefBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: transcript_ref_state::State> TranscriptRefBuilder<'a, S> {
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<'a, S> TranscriptRefBuilder<'a, S>
where
S: transcript_ref_state::State,
S::MimeType: transcript_ref_state::IsUnset,
{
pub fn mime_type(
mut self,
value: impl Into<CowStr<'a>>,
) -> TranscriptRefBuilder<'a, transcript_ref_state::SetMimeType<S>> {
self._fields.1 = Option::Some(value.into());
TranscriptRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TranscriptRefBuilder<'a, S>
where
S: transcript_ref_state::State,
S::Url: transcript_ref_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<'a>>,
) -> TranscriptRefBuilder<'a, transcript_ref_state::SetUrl<S>> {
self._fields.2 = Option::Some(value.into());
TranscriptRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TranscriptRefBuilder<'a, S>
where
S: transcript_ref_state::State,
S::MimeType: transcript_ref_state::IsSet,
S::Url: transcript_ref_state::IsSet,
{
pub fn build(self) -> TranscriptRef<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> TranscriptRef<'a> {
TranscriptRef {
language: self._fields.0,
mime_type: self._fields.1.unwrap(),
url: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}