use std::io;

use crate::{
    library::{
        loudnorm::LoudnormAnalysis,
        track::{Track, track_meta::TrackMeta},
    },
    media_container::MediaContainer,
};

// Core
impl Track {
    pub fn new(container: MediaContainer, metadata: TrackMeta) -> io::Result<Self> {
        Ok(Self {
            container,
            metadata,
            loudnorm_analysis: None,
        })
    }
}

// Accessors
impl Track {
    #[must_use]
    pub fn container(&self) -> &MediaContainer {
        &self.container
    }

    #[must_use]
    pub fn loudnorm_analysis(&self) -> Option<&LoudnormAnalysis> {
        self.loudnorm_analysis.as_ref()
    }

    #[must_use]
    pub fn is_single(&self) -> bool {
        self.metadata.album.is_none()
    }
}
