Added function to make coverart init easier
Some checks failed
Rust Build / Check (pull_request) Successful in 29s
Rust Build / Test Suite (pull_request) Successful in 34s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 28s
Rust Build / build (pull_request) Successful in 33s
Some checks failed
Rust Build / Check (pull_request) Successful in 29s
Rust Build / Test Suite (pull_request) Successful in 34s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 28s
Rust Build / build (pull_request) Successful in 33s
This commit is contained in:
@@ -10,6 +10,32 @@ pub struct CoverArt {
|
|||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod init {
|
||||||
|
use crate::coverart::CoverArt;
|
||||||
|
|
||||||
|
pub fn init_coverart_only_path(path: &String) -> CoverArt {
|
||||||
|
CoverArt {
|
||||||
|
id: uuid::Uuid::new_v4(),
|
||||||
|
title: String::new(),
|
||||||
|
path: path.clone(),
|
||||||
|
data: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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);
|
||||||
|
|
||||||
|
assert_eq!(path, coverart.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CoverArt {
|
impl CoverArt {
|
||||||
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
|
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
|
||||||
let path: &String = &self.path;
|
let path: &String = &self.path;
|
||||||
|
@@ -28,6 +28,7 @@ mod utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
mod song_tests {
|
mod song_tests {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@@ -151,6 +152,7 @@ mod song_tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
mod album_tests {
|
mod album_tests {
|
||||||
|
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
|
Reference in New Issue
Block a user