From a509303bc211e02ad613920c91e80d499456c4d4 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Thu, 17 Sep 2020 20:49:51 -0600 Subject: [PATCH] Add Program model Also expose types for collections of Sections and Programs --- Cargo.toml | 1 + src/model/mod.rs | 4 +++- src/model/program.rs | 23 +++++++++++++++++++++++ src/model/section.rs | 2 ++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/model/program.rs diff --git a/Cargo.toml b/Cargo.toml index 67e5687..6d5f7b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ tokio = { version = "0.2.22", features = ["rt-core", "time", "sync", "macros", " tracing = { version = "0.1.19", features = ["log"] } tracing-futures = "0.2.4" pin-project = "0.4.23" +im = "15.0.0" [dependencies.tracing-subscriber] version = "0.2.11" diff --git a/src/model/mod.rs b/src/model/mod.rs index 6880e5d..8e22b50 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -1,3 +1,5 @@ +mod program; mod section; -pub use section::{Section, SectionRef}; +pub use program::{Program, ProgramId, ProgramItem, ProgramRef, ProgramSequence, Programs}; +pub use section::{Section, SectionId, SectionRef, Sections}; diff --git a/src/model/program.rs b/src/model/program.rs new file mode 100644 index 0000000..c76f8a4 --- /dev/null +++ b/src/model/program.rs @@ -0,0 +1,23 @@ +use std::{time::Duration, sync::Arc}; +use super::section::SectionId; + +#[derive(Debug, Clone)] +pub struct ProgramItem { + pub section_id: SectionId, + pub duration: Duration, +} + +pub type ProgramSequence = Vec; + +pub type ProgramId = u32; + +#[derive(Debug, Clone)] +pub struct Program { + pub id: ProgramId, + pub name: String, + pub sequence: ProgramSequence, +} + +pub type ProgramRef = Arc; + +pub type Programs = im::OrdMap; diff --git a/src/model/section.rs b/src/model/section.rs index 3578cf0..4e5dd4b 100644 --- a/src/model/section.rs +++ b/src/model/section.rs @@ -27,3 +27,5 @@ impl Section { } pub type SectionRef = Arc
; + +pub type Sections = im::OrdMap;