Cleanup
This commit is contained in:
14
src/song.rs
14
src/song.rs
@@ -1,12 +1,12 @@
|
|||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
|
use rand::Rng;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::constants;
|
use crate::constants;
|
||||||
use crate::init;
|
use crate::init;
|
||||||
use crate::types;
|
use crate::types;
|
||||||
|
|
||||||
use rand::Rng;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct Song {
|
pub struct Song {
|
||||||
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
||||||
@@ -170,8 +170,13 @@ impl Song {
|
|||||||
// TODO: Add function to remove file from the filesystem
|
// TODO: Add function to remove file from the filesystem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// I/O operations for songs
|
||||||
|
pub mod io {
|
||||||
/// Copies a song using the source song's data
|
/// Copies a song using the source song's data
|
||||||
pub fn copy_song(song_source: &Song, song_target: &mut Song) -> Result<(), std::io::Error> {
|
pub fn copy_song(
|
||||||
|
song_source: &super::Song,
|
||||||
|
song_target: &mut super::Song,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
match song_target.song_path() {
|
match song_target.song_path() {
|
||||||
Ok(songpath) => {
|
Ok(songpath) => {
|
||||||
let p = std::path::Path::new(&songpath);
|
let p = std::path::Path::new(&songpath);
|
||||||
@@ -196,3 +201,4 @@ pub fn copy_song(song_source: &Song, song_target: &mut Song) -> Result<(), std::
|
|||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user