Add Program model

Also expose types for collections of Sections and Programs
This commit is contained in:
Alex Mikhalev 2020-09-17 20:49:51 -06:00
parent 46d90b4e84
commit a509303bc2
4 changed files with 29 additions and 1 deletions

View File

@ -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"

View File

@ -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};

23
src/model/program.rs Normal file
View File

@ -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<ProgramItem>;
pub type ProgramId = u32;
#[derive(Debug, Clone)]
pub struct Program {
pub id: ProgramId,
pub name: String,
pub sequence: ProgramSequence,
}
pub type ProgramRef = Arc<Program>;
pub type Programs = im::OrdMap<ProgramId, ProgramRef>;

View File

@ -27,3 +27,5 @@ impl Section {
}
pub type SectionRef = Arc<Section>;
pub type Sections = im::OrdMap<SectionId, SectionRef>;