Skip to content

Commit

Permalink
Move common utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
shymega committed Aug 20, 2023
1 parent 6165824 commit a5d0f6f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sources/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::BTreeMap;

/// Struct for a song.
#[derive(Debug, Default)]
pub(crate) struct Song {
Expand All @@ -10,3 +12,16 @@ pub(crate) struct Song {
track: Option<String>,
composer: Option<String>,
}

/// SongTags is a representation of the tags associated with a
/// song. This is a BTreeMap with two Strings.
pub(crate) type SongTags = BTreeMap<String, String>;

/// This function takes tags of SongTags type, and a tag to retrieve.
pub(crate) fn get_tag(tags: &SongTags, tag: &str) -> Option<String> {
return if let Some(x) = tags.get(tag) {
Some(x.to_string())
} else {
None
}
}

0 comments on commit a5d0f6f

Please sign in to comment.