Skip to main content

rodecaster_protocol/names/
show.rs

1//! Show-system parameter families: [`ShowParam`] (per-show), [`CurrentShowParam`]
2//! (the loaded show), and [`ShowControlParam`] (the show-lifecycle command
3//! channel).
4
5// The seven properties each SHOW node carries under the SHOWS container
6// (confirmed from capture, firmware 1.7.3): identity (name / UID / UUID),
7// storage location, snapshot index, an icon, and a modification timestamp.
8wire_param_enum! {
9    /// A per-show parameter: one of the flat properties the device carries on
10    /// each `SHOW` child under the singleton `SHOWS` container. `Uid` is a
11    /// stable integer; `Uuid` is a canonical string identifier;
12    /// `SnapshotIndex` selects which snapshot of the show is active;
13    /// `LastModification` is a wall-clock timestamp string.
14    ShowParam {
15    Icon => "showIcon",
16    LastModification => "showLastModification",
17    Name => "showName",
18    SnapshotIndex => "showSnapshotIndex",
19    StorageType => "showStorageType",
20    Uid => "showUID",
21    Uuid => "showUUID",
22    }
23}
24
25// The three properties the singleton CURRENTSHOW node carries (confirmed from
26// capture, firmware 1.7.3): the identity of the show that's currently loaded.
27wire_param_enum! {
28    /// A currently-loaded-show parameter: one of the flat properties the
29    /// device carries on the singleton `CURRENTSHOW` node. Reflects which
30    /// [`ShowParam`]-addressed show is currently active on the device.
31    CurrentShowParam {
32    Icon => "currentShowIcon",
33    Name => "currentShowName",
34    Uuid => "currentShowUUID",
35    }
36}
37
38// The ten properties the singleton SHOWCONTROL node carries (confirmed from
39// capture, firmware 1.7.3): the write-channel for show lifecycle actions
40// (delete / export / import / new-from-default) plus read-back progress and
41// the last-error string.
42wire_param_enum! {
43    /// A show-lifecycle-command parameter: one of the flat properties the
44    /// device carries on the singleton `SHOWCONTROL` node. This is the
45    /// write channel for creating, deleting, exporting, and importing
46    /// shows (`showControlDelete`, `showControlExport`, `showControlImport`,
47    /// `showControlNewFromDefault*`), plus the read-back `showControlProgress`
48    /// and `showControlLastError` for observing an in-progress action.
49    ShowControlParam {
50    Delete => "showControlDelete",
51    Export => "showControlExport",
52    ExportImport => "showControlExportImport",
53    Import => "showControlImport",
54    LastError => "showControlLastError",
55    LockoutCentral => "showControlLockoutCentral",
56    NewFromDefault => "showControlNewFromDefault",
57    NewFromDefaultMuted => "showControlNewFromDefaultMuted",
58    Progress => "showControlProgress",
59    Updating => "showControlUpdating",
60    }
61}
62
63#[cfg(test)]
64mod tests {
65    use super::*;
66
67    #[test]
68    fn show_param_name_round_trips() {
69        let params = [
70            ShowParam::Icon,
71            ShowParam::LastModification,
72            ShowParam::Name,
73            ShowParam::SnapshotIndex,
74            ShowParam::StorageType,
75            ShowParam::Uid,
76            ShowParam::Uuid,
77        ];
78        for p in params {
79            assert_eq!(ShowParam::from_name(p.as_str()), p);
80            assert!(p.is_known());
81        }
82        assert_eq!(ShowParam::Uid.as_str(), "showUID");
83        assert_eq!(ShowParam::Uuid.as_str(), "showUUID");
84    }
85
86    #[test]
87    fn current_show_param_name_round_trips() {
88        for p in [
89            CurrentShowParam::Icon,
90            CurrentShowParam::Name,
91            CurrentShowParam::Uuid,
92        ] {
93            assert_eq!(CurrentShowParam::from_name(p.as_str()), p);
94            assert!(p.is_known());
95        }
96    }
97
98    #[test]
99    fn show_control_param_name_round_trips_all_ten() {
100        let params = [
101            ShowControlParam::Delete,
102            ShowControlParam::Export,
103            ShowControlParam::ExportImport,
104            ShowControlParam::Import,
105            ShowControlParam::LastError,
106            ShowControlParam::LockoutCentral,
107            ShowControlParam::NewFromDefault,
108            ShowControlParam::NewFromDefaultMuted,
109            ShowControlParam::Progress,
110            ShowControlParam::Updating,
111        ];
112        for p in params {
113            assert_eq!(ShowControlParam::from_name(p.as_str()), p);
114            assert!(p.is_known());
115        }
116    }
117}