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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use crate::;
/// The core trait to be implemented for all types that represent an invokable command
///
/// All [`Command`]s specify the parameters for both the command and the response body. In the
/// case where either the command or response has no parameters, the [`NoParameters`](crate::NoParameters)
/// can be specified.
///
/// # Example
///
/// ```rust
/// use regiface::{Command, ToByteArray, FromByteArray, NoParameters};
///
/// struct GetTemperature;
///
/// impl Command for GetTemperature {
/// type IdType = u8;
/// type CommandParameters = NoParameters;
/// type ResponseParameters = Temperature;
///
/// fn id() -> Self::IdType {
/// 0x42
/// }
///
/// fn invoking_parameters(self) -> Self::CommandParameters {
/// NoParameters::default()
/// }
/// }
///
/// struct Temperature {
/// celsius: f32
/// }
///
/// impl FromByteArray for Temperature {
/// type Error = core::convert::Infallible;
/// type Array = [u8; 4];
///
/// fn from_bytes(bytes: Self::Array) -> Result<Self, Self::Error> {
/// let celsius = f32::from_be_bytes(bytes);
/// Ok(Self { celsius })
/// }
/// }
/// ```
/// A utility type for use when defining a [`Command`] that should pass no parameters, or
/// a [`Command`] that returns no parameters.
///
/// Instances of [`NoParameters`] should be constructed using the `default()` implementation
/// A utility type for use when defining a [`Command`] that should pass a set of zero
/// values as its command parameters.
///
/// Instances of [`Zeros`] should be constructed using the `default()` implementation