Skip to main content

sim_lib_music_serial/
reading.rs

1//! Named readings over immutable serial-plan evidence.
2
3use crate::{PlannedSerialEvent, SerialRole};
4
5/// Reproducible reading scope used when evaluating one serial practice.
6#[derive(Copy, Clone, Debug, PartialEq, Eq)]
7pub enum SerialReading {
8    /// Read only the structural row statement.
9    StructuralPlan,
10    /// Read all events while preserving their declared structural or derived roles.
11    DeclaredRoles,
12    /// Read every sounding event regardless of role boundaries.
13    AllSounding,
14}
15
16impl SerialReading {
17    /// Returns the stable reading token.
18    pub const fn as_str(self) -> &'static str {
19        match self {
20            Self::StructuralPlan => "structural-plan",
21            Self::DeclaredRoles => "declared-roles",
22            Self::AllSounding => "all-sounding",
23        }
24    }
25
26    pub(crate) const fn includes_event(self, event: &PlannedSerialEvent) -> bool {
27        match self {
28            Self::StructuralPlan => matches!(event.role, SerialRole::Structural),
29            Self::DeclaredRoles | Self::AllSounding => true,
30        }
31    }
32}