Browse Source

Add Program model

Also expose types for collections of Sections and Programs
master
Alex Mikhalev 4 years ago
parent
commit
a509303bc2
  1. 1
      Cargo.toml
  2. 4
      src/model/mod.rs
  3. 23
      src/model/program.rs
  4. 2
      src/model/section.rs

1
Cargo.toml

@ -15,6 +15,7 @@ tokio = { version = "0.2.22", features = ["rt-core", "time", "sync", "macros", " @@ -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"

4
src/model/mod.rs

@ -1,3 +1,5 @@ @@ -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

@ -0,0 +1,23 @@ @@ -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>;

2
src/model/section.rs

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

Loading…
Cancel
Save