1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#[cfg(test)] mod tests; use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct Song { pub file: String, pub start: Timestamp, pub stop: Timestamp, } pub type Deck = u8; pub type Timestamp = u64; #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct Loaded { pub deck: Deck, #[serde(flatten)] pub song: Song, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct Transport { pub deck: Deck, pub position: Timestamp, pub length: Timestamp, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct Meta { pub meta: HashMap<String, String>, } #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] #[serde(tag = "type")] pub enum Message { Want, Skip, Status, Quit, Next(Song), Loaded(Loaded), Playing(Transport), Stopped(Transport), MetaInfo(Meta), }