Compare commits
2 Commits
dev-v0.1.1
...
dev-v0.1.1
Author | SHA1 | Date | |
---|---|---|---|
950a70ccad | |||
7f8649ee38 |
27
src/coverart.rs
Normal file
27
src/coverart.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
pub mod access_level;
|
||||
pub mod album;
|
||||
pub mod constants;
|
||||
pub mod coverart;
|
||||
pub mod login_result;
|
||||
pub mod song;
|
||||
pub mod token;
|
||||
|
18
src/song.rs
18
src/song.rs
@@ -159,23 +159,13 @@ impl Song {
|
||||
let filename_len = 10;
|
||||
|
||||
let file_extension = match typ {
|
||||
types::types::Types::DefaultMusicExtension =>
|
||||
{
|
||||
types::types::Types::DefaultMusicExtension => {
|
||||
String::from(constants::DEFAULTMUSICEXTENSION)
|
||||
}
|
||||
|
||||
types::types::Types::WavExtension =>
|
||||
{
|
||||
String::from(constants::WAVEXTENSION)
|
||||
}
|
||||
types::types::Types::FlacExtension =>
|
||||
{
|
||||
String::from(constants::FLACEXTENSION)
|
||||
}
|
||||
types::types::Types::MPThreeExtension =>
|
||||
{
|
||||
String::from(constants::MPTHREEEXTENSION)
|
||||
}
|
||||
types::types::Types::WavExtension => String::from(constants::WAVEXTENSION),
|
||||
types::types::Types::FlacExtension => String::from(constants::FLACEXTENSION),
|
||||
types::types::Types::MPThreeExtension => String::from(constants::MPTHREEEXTENSION),
|
||||
};
|
||||
|
||||
if randomize {
|
||||
|
Reference in New Issue
Block a user