selene-core 0.9.0-rc.1

Backend for selene-server
Documentation
#![forbid(unsafe_code)]

use lunar_lib::paths::init_directories;
use selene_common::{Id, PROGRAM_FS_NAME};

pub mod config;

pub mod database;

pub mod library;
pub mod media;

pub mod transcoding;

pub mod accounts;

pub fn init_dirs() -> Result<(), &'static str> {
    init_directories(PROGRAM_FS_NAME)
}

pub trait SeleneIdExt<T> {
    /// Gets an ID from the hash of a string. This will not work for tracks, which require the hash of the source file
    fn from_string_hash(string: impl AsRef<str>) -> Self;
}

impl<T> SeleneIdExt<T> for Id<T> {
    fn from_string_hash(string: impl AsRef<str>) -> Self {
        let hash = blake3::hash(string.as_ref().to_lowercase().as_bytes());
        Self::from(*hash.as_bytes())
    }
}