Add XML schema to be used with serde
This commit is contained in:
parent
f3b5bfe6f4
commit
b67f440dd8
3 changed files with 68 additions and 0 deletions
|
@ -7,3 +7,5 @@ license = "GPL-3.0-or-later"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.0.18", features = ["derive"] }
|
clap = { version = "4.0.18", features = ["derive"] }
|
||||||
rodio = "0.16.0"
|
rodio = "0.16.0"
|
||||||
|
serde = { version = "1.0.147", features = ["derive"] }
|
||||||
|
serde-xml-rs = "0.6.0"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
mod xml;
|
||||||
|
|
||||||
fn play_file(file: &str) {
|
fn play_file(file: &str) {
|
||||||
use rodio::{Decoder, OutputStream, source::Source};
|
use rodio::{Decoder, OutputStream, source::Source};
|
||||||
|
|
||||||
|
|
63
src/xml.rs
Normal file
63
src/xml.rs
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
// https://github.com/UoC-Radio/audio-scheduler/blob/45275818423220de90b4ae578b57acdc138e5f50/config_schema.xsd
|
||||||
|
// TODO: Extensively check constraints such as `minOccurs` and `use="required".
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Fader {
|
||||||
|
fade_in_duration_secs: i8,
|
||||||
|
fade_out_duration_secs: i8,
|
||||||
|
min_level: f32,
|
||||||
|
max_level: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Playlist {
|
||||||
|
path: String,
|
||||||
|
shuffle: bool,
|
||||||
|
fader: Fader,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct IntermediatePlaylist {
|
||||||
|
path: String,
|
||||||
|
shuffle: bool,
|
||||||
|
fader: Fader,
|
||||||
|
sched_interval_mins: u16,
|
||||||
|
num_sched_items: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
enum ZoneContent {
|
||||||
|
Main(Playlist),
|
||||||
|
Fallback(Playlist),
|
||||||
|
Intermediate(IntermediatePlaylist),
|
||||||
|
Maintainer(String),
|
||||||
|
Description(String),
|
||||||
|
Comment(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Zone {
|
||||||
|
name: String,
|
||||||
|
// TODO: Use a time struct
|
||||||
|
start: String,
|
||||||
|
zone_content: ZoneContent,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Day {
|
||||||
|
zones: Vec<Zone>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct WeekSchedule {
|
||||||
|
mon: Day,
|
||||||
|
tue: Day,
|
||||||
|
wed: Day,
|
||||||
|
thu: Day,
|
||||||
|
fri: Day,
|
||||||
|
sat: Day,
|
||||||
|
sun: Day,
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue