moved queue to its own file

This commit is contained in:
MrDulfin 2024-02-24 20:25:56 -05:00
parent 74e2933de1
commit 0e6a676e09
3 changed files with 27 additions and 23 deletions

View file

@ -13,6 +13,7 @@ pub mod music_storage {
pub mod music_controller{ pub mod music_controller{
pub mod controller; pub mod controller;
pub mod connections; pub mod connections;
pub mod queue;
} }
pub mod music_player; pub mod music_player;

View file

@ -24,31 +24,9 @@ use crate::{
music_player::Player, music_player::Player,
music_storage::library::{MusicLibrary, Song}, music_storage::library::{MusicLibrary, Song},
config::config::Config, config::config::Config,
music_controller::queue::Queue,
}; };
struct Queue {
player: Player,
name: String,
songs: Vec<Song>,
}
impl Queue {
fn new() -> Result<Self, Box<dyn Error>> {
Ok(
Queue {
player: Player::new()?,
name: String::new(),
songs: Vec::new()
}
)
}
fn set_tracks(&mut self, tracks: Vec<Song>) {
let mut tracks = tracks;
self.songs.clear();
self.songs.append(&mut tracks);
}
}
pub struct Controller { pub struct Controller {
// queues: Vec<Queue>, // queues: Vec<Queue>,
config: Arc<RwLock<Config>>, config: Arc<RwLock<Config>>,

View file

@ -0,0 +1,25 @@
use crate::{music_player::Player, music_storage::library::Song};
use std::error::Error;
pub struct Queue {
pub player: Player,
pub name: String,
pub songs: Vec<Song>,
}
impl Queue {
pub fn new() -> Result<Self, Box<dyn Error>> {
Ok(
Queue {
player: Player::new()?,
name: String::new(),
songs: Vec::new()
}
)
}
pub fn set_tracks(&mut self, tracks: Vec<Song>) {
let mut tracks = tracks;
self.songs.clear();
self.songs.append(&mut tracks);
}
}