1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! [`StorageVolumeParam`]: per-`STORAGEVOLUME`-node parameter family.
// The eleven properties a real Pro II / Duo fullSync carries on each
// STORAGEVOLUME node (confirmed from capture, firmware 1.7.3). One volume is
// the SD card; there may be more if other storage is attached. `storageVolume`
// nodes address by index: see `Layout::storage_volume_path`.
wire_param_enum! {
/// A storage-volume parameter: one of the flat properties the device
/// carries on each `STORAGEVOLUME` node. Read-back state describes the
/// volume's capacity, free bytes, mount + format status, and the pipe-
/// separated `storageVolumeState` progress string that the device
/// updates live during recording (`total|used|f|f|f`). Command channel
/// props (`Eject`, `Erase`, `Transfer`) request device-side actions.
StorageVolumeParam {
// Identity + capacity.
Name => "storageVolumeName",
Capacity => "storageVolumeCapacity",
Free => "storageVolumeFree",
// Mount / format lifecycle.
Inserted => "storageVolumeInserted",
Mounted => "storageVolumeMounted",
Formatted => "storageVolumeFormatted",
// Recording destination flag + live progress.
RecDestination => "storageVolumeRecDestination",
State => "storageVolumeState",
// Command channel.
Eject => "storageVolumeEject",
Erase => "storageVolumeErase",
Transfer => "storageVolumeTransfer",
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn storage_volume_param_name_round_trips() {
let params = [
StorageVolumeParam::Name,
StorageVolumeParam::Capacity,
StorageVolumeParam::Free,
StorageVolumeParam::Inserted,
StorageVolumeParam::Mounted,
StorageVolumeParam::Formatted,
StorageVolumeParam::RecDestination,
StorageVolumeParam::State,
StorageVolumeParam::Eject,
StorageVolumeParam::Erase,
StorageVolumeParam::Transfer,
];
for p in params {
assert_eq!(StorageVolumeParam::from_name(p.as_str()), p);
assert!(p.is_known());
}
}
#[test]
fn storage_volume_param_state_pipe_string_is_caller_owned() {
// `storageVolumeState` values arrive as pipe-separated strings like
// "15927934976|11134074880|1|1|1": the crate types the property name,
// parsing the fields is the caller's job.
assert_eq!(StorageVolumeParam::State.as_str(), "storageVolumeState");
}
}