Added function to make coverart init easier (#24)

Reviewed-on: phoenix/icarus_models#24
Co-authored-by: phoenix <kundeng94@gmail.com>
Co-committed-by: phoenix <kundeng94@gmail.com>
This commit is contained in:
phoenix
2025-04-04 02:21:31 +00:00
committed by phoenix
parent 61ad88a258
commit 8fbd92620e
5 changed files with 41 additions and 20 deletions
+26
View File
@@ -10,6 +10,19 @@ pub struct CoverArt {
pub data: Vec<u8>,
}
pub mod init {
use crate::coverart::CoverArt;
pub fn init_coverart_only_path(path: String) -> CoverArt {
CoverArt {
id: uuid::Uuid::nil(),
title: String::new(),
path: path.clone(),
data: Vec::new(),
}
}
}
impl CoverArt {
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
let path: &String = &self.path;
@@ -21,3 +34,16 @@ impl CoverArt {
}
}
}
#[cfg(test)]
mod tests {
use crate::coverart;
#[test]
fn test_cover_art_image() {
let path: String = String::from("somepath");
let coverart = coverart::init::init_coverart_only_path(path.clone());
assert_eq!(path, coverart.path);
}
}