selene-core 0.3.0

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

use directories::BaseDirs;

use crate::container::ContainerFormat;

pub const PROGRAM_NAME: &str = "selene";

pub mod codec;
pub mod config;
pub mod container;
pub mod database;
pub mod errors;
mod ffmpeg;
pub mod library;
pub mod media_container;
pub mod utils;

pub const SUPPORTED_CONTAINERS: [ContainerFormat; 4] = [
    ContainerFormat::Flac,
    ContainerFormat::Mp3,
    ContainerFormat::Ogg,
    ContainerFormat::Wav,
];

static BASE_DIRS: LazyLock<Option<BaseDirs>> = LazyLock::new(BaseDirs::new);

/// Returns the users `base_dirs`
///
/// # Panics
///
/// Panics if the internal `BASE_DIRS` static is [`None`]. This can only happen if the home directory is not found
pub fn base_dirs() -> &'static BaseDirs {
    BASE_DIRS.as_ref().unwrap()
}

#[must_use]
pub fn config_dir() -> PathBuf {
    base_dirs().config_dir().join(PROGRAM_NAME)
}

#[must_use]
pub fn data_dir() -> PathBuf {
    base_dirs().data_dir().join(PROGRAM_NAME)
}

#[must_use]
pub fn cache_dir() -> PathBuf {
    base_dirs().cache_dir().join(PROGRAM_NAME)
}