Skip to main content

rodecaster_protocol/names/
recorder.rs

1//! [`RecorderParam`]: the singleton `RECORDER`-node parameter family.
2
3// The five properties a real Pro II / Duo fullSync carries on the single
4// RECORDER node (confirmed from capture, firmware 1.7.3): the multitrack
5// recorder's transport state and the request-to-change-state command channel.
6wire_param_enum! {
7    /// A recorder parameter: one of the flat properties the device carries on
8    /// the single `RECORDER` node. There is exactly one recorder, so this family
9    /// takes no addressing key. The `record*` properties are read-back state
10    /// (current transport, elapsed ms, byte rate); the `request*` properties are
11    /// the write channel (set `requestRecordState` to start/stop recording, set
12    /// `requestDropMarker` to drop a chapter marker).
13    RecorderParam {
14    // Read-back state.
15    RecordState => "recordState",
16    RecordTimeMs => "recordTimeMs",
17    RecordBytesPerSecond => "recordBytesPerSecond",
18    // Write channel (commands).
19    RequestRecordState => "requestRecordState",
20    RequestDropMarker => "requestDropMarker",
21    }
22}
23
24#[cfg(test)]
25mod tests {
26    use super::*;
27
28    #[test]
29    fn recorder_param_name_round_trips() {
30        let params = [
31            RecorderParam::RecordState,
32            RecorderParam::RecordTimeMs,
33            RecorderParam::RecordBytesPerSecond,
34            RecorderParam::RequestRecordState,
35            RecorderParam::RequestDropMarker,
36        ];
37        for p in params {
38            assert_eq!(RecorderParam::from_name(p.as_str()), p);
39            assert!(p.is_known());
40            assert_eq!(p.to_string(), p.as_str());
41        }
42    }
43
44    #[test]
45    fn recorder_param_separates_state_from_command_channel() {
46        // Read-back state vs the request* write channel keep distinct wire names.
47        assert_eq!(RecorderParam::RecordState.as_str(), "recordState");
48        assert_eq!(
49            RecorderParam::RequestRecordState.as_str(),
50            "requestRecordState"
51        );
52        assert_eq!(
53            RecorderParam::RequestDropMarker.as_str(),
54            "requestDropMarker"
55        );
56    }
57
58    #[test]
59    fn recorder_param_unknown_falls_back_to_other() {
60        let p = RecorderParam::from_name("recordMystery");
61        assert_eq!(p, RecorderParam::Other("recordMystery".to_string()));
62        assert!(!p.is_known());
63        assert_eq!(RecorderParam::from_name(p.as_str()), p);
64    }
65}