Added method to save coverart to the filesystem
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
|
use std::io::Write;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct CoverArt {
|
pub struct CoverArt {
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
@@ -26,7 +29,25 @@ pub mod init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CoverArt {
|
impl CoverArt {
|
||||||
// TODO: Add method to save to filesystem
|
/// Saves the coverart to the filesystem
|
||||||
|
pub fn save_to_filesystem(&self) -> Result<(), std::io::Error> {
|
||||||
|
match std::fs::File::create(&self.path) {
|
||||||
|
Ok(mut file) => {
|
||||||
|
match file.write_all(&self.data) {
|
||||||
|
Ok(_) => {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add method to remove from filesystem
|
// TODO: Add method to remove from filesystem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user