Compare commits

..

2 Commits

Author SHA1 Message Date
KD
950a70ccad Merge branch 'coverart' into 'dev'
Added coverart struct

See merge request kdeng00/icarus-models!40
2025-03-21 00:18:38 +00:00
KD
7f8649ee38 Added coverart struct 2025-03-21 00:18:38 +00:00
3 changed files with 32 additions and 14 deletions

27
src/coverart.rs Normal file
View File

@@ -0,0 +1,27 @@
use std::io::Read;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CoverArt {
pub id: i32,
pub title: String,
pub path: String,
pub data: Vec<u8>,
}
impl CoverArt {
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
let path: &String = &self.path;
let mut file = std::fs::File::open(path)?;
let mut buffer = Vec::new();
match file.read_to_end(&mut buffer) {
Ok(_) => {
return Ok(buffer);
}
Err(err) => {
return Err(err);
}
}
}
}

View File

@@ -1,6 +1,7 @@
pub mod access_level; pub mod access_level;
pub mod album; pub mod album;
pub mod constants; pub mod constants;
pub mod coverart;
pub mod login_result; pub mod login_result;
pub mod song; pub mod song;
pub mod token; pub mod token;

View File

@@ -159,23 +159,13 @@ impl Song {
let filename_len = 10; let filename_len = 10;
let file_extension = match typ { let file_extension = match typ {
types::types::Types::DefaultMusicExtension => types::types::Types::DefaultMusicExtension => {
{
String::from(constants::DEFAULTMUSICEXTENSION) String::from(constants::DEFAULTMUSICEXTENSION)
} }
types::types::Types::WavExtension => types::types::Types::WavExtension => String::from(constants::WAVEXTENSION),
{ types::types::Types::FlacExtension => String::from(constants::FLACEXTENSION),
String::from(constants::WAVEXTENSION) types::types::Types::MPThreeExtension => String::from(constants::MPTHREEEXTENSION),
}
types::types::Types::FlacExtension =>
{
String::from(constants::FLACEXTENSION)
}
types::types::Types::MPThreeExtension =>
{
String::from(constants::MPTHREEEXTENSION)
}
}; };
if randomize { if randomize {