vidsage-core 0.1.0

Core functionality for VidSage video processing and AI commentary generation
Documentation
//! Commentary style definitions

use serde::{Deserialize, Serialize};

/// Commentary style enumeration
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum CommentaryStyle {
    #[serde(rename = "professional")]
    Professional, // Formal, technical commentary

    #[serde(rename = "casual")]
    Casual, // Relaxed, conversational style

    #[serde(rename = "educational")]
    Educational, // Informative, teaching-focused

    #[serde(rename = "entertaining")]
    Entertaining, // Engaging, humorous style

    #[serde(rename = "analytical")]
    Analytical, // Data-driven, detailed analysis

    #[serde(rename = "storytelling")]
    Storytelling, // Narrative, storytelling approach

    #[serde(rename = "poetic")]
    Poetic, // Creative, poetic language

    #[serde(rename = "technical")]
    Technical, // Highly technical, detailed explanations
}

impl CommentaryStyle {
    /// Get a display name for the style
    pub fn display_name(&self) -> &'static str {
        match self {
            CommentaryStyle::Professional => "Professional",
            CommentaryStyle::Casual => "Casual",
            CommentaryStyle::Educational => "Educational",
            CommentaryStyle::Entertaining => "Entertaining",
            CommentaryStyle::Analytical => "Analytical",
            CommentaryStyle::Storytelling => "Storytelling",
            CommentaryStyle::Poetic => "Poetic",
            CommentaryStyle::Technical => "Technical",
        }
    }

    /// Get a description for the style
    pub fn description(&self) -> &'static str {
        match self {
            CommentaryStyle::Professional => {
                "Formal, technical commentary suitable for business or academic contexts"
            },
            CommentaryStyle::Casual => {
                "Relaxed, conversational style that feels natural and approachable"
            },
            CommentaryStyle::Educational => {
                "Informative, teaching-focused commentary that explains concepts clearly"
            },
            CommentaryStyle::Entertaining => {
                "Engaging, humorous style that keeps viewers entertained"
            },
            CommentaryStyle::Analytical => "Data-driven, detailed analysis of video content",
            CommentaryStyle::Storytelling => {
                "Narrative, storytelling approach that creates a compelling story"
            },
            CommentaryStyle::Poetic => "Creative, poetic language that adds artistic flair",
            CommentaryStyle::Technical => {
                "Highly technical, detailed explanations of video content"
            },
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use serde_json;

    #[test]
    fn test_commentary_style_display_name() {
        assert_eq!(CommentaryStyle::Professional.display_name(), "Professional");
        assert_eq!(CommentaryStyle::Casual.display_name(), "Casual");
        assert_eq!(CommentaryStyle::Educational.display_name(), "Educational");
        assert_eq!(CommentaryStyle::Entertaining.display_name(), "Entertaining");
        assert_eq!(CommentaryStyle::Analytical.display_name(), "Analytical");
        assert_eq!(CommentaryStyle::Storytelling.display_name(), "Storytelling");
        assert_eq!(CommentaryStyle::Poetic.display_name(), "Poetic");
        assert_eq!(CommentaryStyle::Technical.display_name(), "Technical");
    }

    #[test]
    fn test_commentary_style_description() {
        assert!(!CommentaryStyle::Professional.description().is_empty());
        assert!(!CommentaryStyle::Casual.description().is_empty());
        assert!(!CommentaryStyle::Educational.description().is_empty());
        assert!(!CommentaryStyle::Entertaining.description().is_empty());
        assert!(!CommentaryStyle::Analytical.description().is_empty());
        assert!(!CommentaryStyle::Storytelling.description().is_empty());
        assert!(!CommentaryStyle::Poetic.description().is_empty());
        assert!(!CommentaryStyle::Technical.description().is_empty());
    }

    #[test]
    fn test_commentary_style_serialization() {
        // Test serialization
        let style = CommentaryStyle::Professional;
        let json = serde_json::to_string(&style).unwrap();
        assert_eq!(json, "\"professional\"");

        // Test deserialization
        let deserialized: CommentaryStyle = serde_json::from_str(&json).unwrap();
        assert_eq!(deserialized, CommentaryStyle::Professional);

        // Test deserialization from string
        let deserialized: CommentaryStyle = serde_json::from_str("\"casual\"").unwrap();
        assert_eq!(deserialized, CommentaryStyle::Casual);

        let deserialized: CommentaryStyle = serde_json::from_str("\"educational\"").unwrap();
        assert_eq!(deserialized, CommentaryStyle::Educational);
    }
}