Moved function

This commit is contained in:
2025-10-11 16:00:05 -04:00
parent 0c0b4ba7ca
commit 84c0cda072

View File

@@ -1,5 +1,3 @@
use std::io::Read;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)] #[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
@@ -28,8 +26,17 @@ pub mod init {
} }
impl CoverArt { impl CoverArt {
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
let path: &String = &self.path; // TODO: Add method to save to filesystem
// TODO: Add method to remove from filesystem
}
pub mod io {
use std::io::Read;
/// Gets the raw data of the cover art
pub fn to_data(coverart: &super::CoverArt) -> Result<Vec<u8>, std::io::Error> {
let path: &String = &coverart.path;
let mut file = std::fs::File::open(path)?; let mut file = std::fs::File::open(path)?;
let mut buffer = Vec::new(); let mut buffer = Vec::new();
match file.read_to_end(&mut buffer) { match file.read_to_end(&mut buffer) {
@@ -37,9 +44,6 @@ impl CoverArt {
Err(err) => Err(err), Err(err) => Err(err),
} }
} }
// TODO: Add method to save to filesystem
// TODO: Add method to remove from filesystem
} }
#[cfg(test)] #[cfg(test)]