use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
use crate::catalog::hang::CatalogExt;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(rename_all = "camelCase")]
pub struct Cues {
pub renditions: BTreeMap<String, Config>,
}
impl Cues {
pub fn is_empty(&self) -> bool {
self.renditions.is_empty()
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct Config {
#[serde(default)]
pub container: hang::catalog::Container,
}
impl Config {
pub fn new() -> Self {
Self::default()
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
pub struct Ext {
#[serde(default, skip_serializing_if = "Cues::is_empty")]
pub scte35: Cues,
}
impl CatalogExt for Ext {}
pub trait Catalog: CatalogExt {
fn scte35_mut(&mut self) -> Option<&mut Cues>;
}
impl Catalog for () {
fn scte35_mut(&mut self) -> Option<&mut Cues> {
None
}
}
impl Catalog for Ext {
fn scte35_mut(&mut self) -> Option<&mut Cues> {
Some(&mut self.scte35)
}
}