selene-core 0.5.4

selene-core is the backend for Selene, a local-first music player
Documentation
use std::path::{Path, PathBuf};

use crate::utils::pair_extension;
use serde::{Deserialize, Serialize};

mod channel_layout;
pub use channel_layout::*;

mod codec;
pub use codec::*;

mod format;
pub use format::*;

mod sample_format;
pub use sample_format::*;

mod stream;
pub use stream::*;

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct MediaContainer {
    pub(crate) path: PathBuf,
    pub(crate) format: ContainerFormat,
    pub(crate) stream: Stream,
}

impl MediaContainer {
    pub(crate) fn set_path(&mut self, path: PathBuf) {
        self.path = path;
    }
}

impl MediaContainer {
    #[must_use]
    pub fn path(&self) -> &Path {
        &self.path
    }

    #[must_use]
    pub fn format(&self) -> &ContainerFormat {
        &self.format
    }

    /// Returns the file extension this [`MediaContainer`] uses. Returns [`Option::None`] for invalid or unrecognized pairs
    #[must_use]
    pub fn extension(&self) -> &'static str {
        pair_extension(self.format, self.stream.codec_params.codec)
    }

    #[must_use]
    pub fn stream(&self) -> &Stream {
        &self.stream
    }
}