Skip to content
Extraits de code Groupes Projets
Valider fd2babb6 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

WIP: We will load and write patch files for the database with auxiliary types.

parent 47f14a3f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -9,17 +9,15 @@ use lru::LruCache;
/// cache, if its the playlists that are updated, we clear only the playlist, if
/// it's the database, we clear everything.
#[allow(dead_code)]
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug)]
pub struct AmaDB {
/// Cache requests to lektord and patched karas. The first element is the
/// lektord entry, the second one is the patched version.
/// TODO: Find a structure that does COW to not duplicate too much
/// information in the patched version...
#[serde(skip, default = "new_empty_kara_lru")]
karas: LruCache<i64, (KaraInfo, Option<KaraInfo>)>,
/// The playlists. We don't save them...
#[serde(skip, default = "new_empty_playlist_lru")]
playlists: LruCache<SmallString, Playlist>,
/// The list of overrides, indexed by the local id of the kara.
......@@ -56,6 +54,9 @@ fn new_empty_playlist_lru() -> LruCache<SmallString, Playlist> {
}
impl AmaDB {
/// Create a new empty [AmaDB].
pub fn new() -> Self {}
/// Clear the database cache, and only the caches about karas.
pub fn clear_database_cache(&mut self) {
todo!()
......
......@@ -4,7 +4,7 @@ use crate::*;
/// Represent the possible types for a song. The custom field is here for
/// flexibility, we box it so it's not too big and because it won't be common.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SongType {
OP,
ED,
......@@ -16,8 +16,7 @@ pub enum SongType {
/// Represent the possible origins for a song. The custom field is here for
/// flexibility, we box it so it's not too big and because it won't be common.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SongOrigin {
Anime,
VN,
......@@ -28,7 +27,7 @@ pub enum SongOrigin {
}
/// Represent a global id for a kara, the pair (database, id).
#[derive(Debug, Deserialize, Serialize, Getters, CopyGetters)]
#[derive(Debug, Getters, CopyGetters)]
pub struct KaraId {
#[getset(get = "pub")]
repo: SmallString,
......@@ -108,7 +107,7 @@ impl<'a> TaggedObject<'a> for KaraInfo {
}
/// Represent what we want to override in a kara.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone)]
pub enum KaraInfoOverride {
SongTitle(SmallString),
SongSource(SmallString),
......@@ -153,3 +152,29 @@ impl KaraInfo {
!= 0
}
}
impl From<&str> for SongOrigin {
fn from(value: &str) -> Self {
match value {
"anime" => SongOrigin::Anime,
"music" => SongOrigin::Music,
"autre" => SongOrigin::Autre,
"game" => SongOrigin::Game,
"vb" => SongOrigin::VN,
custom => SongOrigin::Custom(Box::new(custom.into())),
}
}
}
impl From<&str> for SongType {
fn from(value: &str) -> Self {
match value {
"OP" => SongType::OP,
"ED" => SongType::ED,
"IS" => SongType::IS,
"MV" => SongType::MV,
"OT" => SongType::OT,
custom => SongType::Custom(Box::new(custom.into())),
}
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter