xmltv 2.1.1

XMLTV for electronic program guide (EPG) parser and generator using serde.
Documentation
//! Shared primitive types used throughout the XMLTV data model.
use serde::{Deserialize, Serialize};

/// A text value with an optional BCP-47 language tag, used for display names, country names, etc.
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, Default)]
pub struct NameAndLang {
    #[serde(rename = "$text", skip_serializing_if = "String::is_empty")]
    pub name: String,
    #[serde(skip_serializing_if = "Option::is_none", rename = "@lang")]
    pub lang: Option<String>,
}

/// A text value with an optional BCP-47 language tag, used for titles, descriptions, etc.
///
/// `Deserialize` is implemented manually in `utils` to handle both map and sequence access.
#[derive(Debug, PartialEq, Clone, Serialize, Default)]
pub struct ValueAndLang {
    #[serde(rename = "$text", skip_serializing_if = "String::is_empty")]
    pub value: String,
    #[serde(skip_serializing_if = "Option::is_none", rename = "@lang")]
    pub lang: Option<String>,
}

/// An empty XML tag (no attributes, no text content), e.g. `<new/>`.
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct EmptyTag {}

/// An XML element whose only content is a text node: `<tag>value</tag>`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct TagWithOnlyText {
    #[serde(rename = "$text")]
    pub value: String,
}

/// An icon (image) associated with a channel or programme.
///
/// ```dtd
/// <!ELEMENT icon EMPTY>
/// <!ATTLIST icon src    CDATA #REQUIRED
///                width  CDATA #IMPLIED
///                height CDATA #IMPLIED>
/// ```
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct Icon {
    #[serde(rename = "@src")]
    pub src: String,
    #[serde(skip_serializing_if = "Option::is_none", rename = "@width")]
    pub width: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none", rename = "@height")]
    pub height: Option<String>,
}