messing around with config

This commit is contained in:
MrDulfin 2024-01-17 05:53:18 -05:00
parent 2d0464a993
commit bc75b92237
7 changed files with 119 additions and 18 deletions

View file

@ -34,3 +34,4 @@ leb128 = "0.2.5"
urlencoding = "2.1.3" urlencoding = "2.1.3"
m3u8-rs = "5.0.5" m3u8-rs = "5.0.5"
thiserror = "1.0.56" thiserror = "1.0.56"
font = "0.27.0"

16
src/config/config.rs Normal file
View file

@ -0,0 +1,16 @@
use std::{path::PathBuf, marker::PhantomData};
#[derive(Debug, Default)]
pub struct Config {
db_path: Option<PathBuf>,
}
impl Config {
pub fn new_main() -> Self {
Config::default()
}
//TODO: Add new function for test tube
pub fn load(&self) {
}
}

View file

@ -0,0 +1,82 @@
use std::{marker::PhantomData, fs::File, path::PathBuf};
use font::Font;
pub trait Setting {}
pub struct DropDown {
name: String,
//value: ???
}
impl Setting for DropDown {}
#[derive(Debug, Default)]
pub struct Slider {
name: String,
value: i32,
}
impl Setting for Slider {}
#[derive(Debug, Default)]
pub struct CheckBox {
name: String,
value: bool,
}
impl Setting for CheckBox {}
enum TextBoxSize {
Small,
Large,
}
#[derive(Debug, Default)]
pub struct TextBox<Size = TextBoxSize> {
name: String,
text: String,
size: PhantomData<Size>
}
impl Setting for TextBox {}
#[derive(Debug, Default)]
pub struct SingleSelect {
name: String,
value: bool,
}
impl Setting for SingleSelect {}
#[derive(Debug, Default)]
pub struct MultiSelect {
name: String,
value: bool,
}
impl Setting for MultiSelect {}
#[derive(Debug, Default)]
pub struct ConfigCounter {
name: String,
value: i32,
}
impl Setting for ConfigCounter {}
#[derive(Debug, Default)]
pub struct ConfigFont {
name: String,
value: Font,
}
impl Setting for ConfigFont {}
#[derive(Debug, Default)]
pub struct ConfigFile {
name: String,
value: PathBuf,
}
impl Setting for ConfigFile {}
#[derive(Debug, Default)]
pub struct List<T: Setting> {
items: Vec<T>
}
pub struct Form {
}

View file

@ -3,21 +3,11 @@ pub mod music_storage {
pub mod music_collection; pub mod music_collection;
pub mod playlist; pub mod playlist;
mod utils; mod utils;
pub mod db_reader { pub mod db_reader;
pub mod foobar {
pub mod reader;
pub mod utils;
}
pub mod musicbee {
pub mod reader;
pub mod utils;
}
pub mod xml {
pub mod reader;
}
pub mod common;
pub mod extern_library;
}
} }
pub mod music_player; pub mod music_player;
pub mod config {
pub mod config;
pub mod other_settings;
}

View file

@ -0,0 +1,13 @@
pub mod foobar {
pub mod reader;
pub mod utils;
}
pub mod musicbee {
pub mod reader;
pub mod utils;
}
pub mod xml {
pub mod reader;
}
pub mod common;
pub mod extern_library;

View file

@ -92,7 +92,6 @@ impl ExternalLibrary for XmlLibrary {
} }
let text = e.unescape().unwrap().to_string(); let text = e.unescape().unwrap().to_string();
if text == count2.to_string() && !key_selected { if text == count2.to_string() && !key_selected {
continue; continue;
} }
@ -118,8 +117,7 @@ impl ExternalLibrary for XmlLibrary {
buf.clear(); buf.clear();
} }
let elasped = now.elapsed(); let elasped = now.elapsed();
println!("\n\nXMLReader\n=========================================\n\nDone!\n{} songs grabbed in {:#?}\nIDs Skipped: {}", count3, elasped, count4); println!("\n\nXMLReader grabbed {} songs in {:#?} seconds\nIDs Skipped: {}", count3, elasped.as_secs(), count4);
// dbg!(folder);
let mut lib = XmlLibrary::new(); let mut lib = XmlLibrary::new();
lib.tracks.append(converted_songs.as_mut()); lib.tracks.append(converted_songs.as_mut());
lib lib

View file

@ -102,6 +102,7 @@ impl<'a> Playlist<'a> {
segments: seg.clone(), segments: seg.clone(),
..Default::default() ..Default::default()
}; };
//TODO: change this to put in a real file path
let mut file = std::fs::OpenOptions::new() let mut file = std::fs::OpenOptions::new()
.read(true) .read(true)
.create(true) .create(true)