diff --git a/src/rust/amalib/src/db_cache.rs b/src/rust/amalib/src/db_cache.rs index 755235fa6106c4525247d3a3aea888c4db89ff8f..e51ba7ed62fae79268f59e9a2e9642f19594769e 100644 --- a/src/rust/amalib/src/db_cache.rs +++ b/src/rust/amalib/src/db_cache.rs @@ -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!() diff --git a/src/rust/amalib/src/db_kara.rs b/src/rust/amalib/src/db_kara.rs index bda0b88c2eb7e49f2870e7ef01b22ab22d926f39..d635786bccca8673bbc0d20609fed255f72dbf6e 100644 --- a/src/rust/amalib/src/db_kara.rs +++ b/src/rust/amalib/src/db_kara.rs @@ -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())), + } + } +}