Added function to make coverart init easier (#24)
All checks were successful
Release Tagging / release (push) Successful in 32s
Rust Build / Check (push) Successful in 29s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Clippy (push) Successful in 26s
Rust Build / build (push) Successful in 32s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Clippy (pull_request) Successful in 28s
Rust Build / build (pull_request) Successful in 28s
Rust Build / Check (pull_request) Successful in 31s
Rust Build / Test Suite (pull_request) Successful in 38s

Reviewed-on: #24
Co-authored-by: phoenix <kundeng94@gmail.com>
Co-committed-by: phoenix <kundeng94@gmail.com>
This commit is contained in:
2025-04-04 02:21:31 +00:00
committed by phoenix
parent 61ad88a258
commit 8fbd92620e
5 changed files with 41 additions and 20 deletions

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);
}
}