aboutsummaryrefslogtreecommitdiff
path: root/src/commands.rs
Commit message (Collapse)AuthorAge
* Remove label from assert_maximum_size macroRobin Krahl2019-12-17
| | | | | | Since static_assertions 1.0.0, we no longer have to specify a label when calling an assert macro. Therefore we can also remove the label from our own assert macro assert_maximum_size.
* Assert maximum size for command request and response structsRobin Krahl2019-02-20
| | | | | | The request and response structs for a command should not be bigger than the buffer they are read from or written to. Therefore we add assertions that enforce this property at compile time.
* Use arrays instead of slices where possibleRobin Krahl2019-02-20
| | | | | To increase type safety, we use references to (sized) arrays instead of slices where possible.
* Rename commands::COMMAND_LEN to device::RESPONSE_DATA_LENRobin Krahl2019-02-20
| | | | | | | | | Previously, we had the device::REQUEST_DATA_LEN constant for the size of the raw data in the request, and the commands::COMMAND_LEN constant for the size of the raw data in the response. This patch renames commands::COMMAND_LEN to device::RESPONSE_DATA_LEN for consistency. It also introduces the {Request,Response}Data type aliases for [u8; {REQUEST,RESPONSE}_DATA_LEN].
* Refactor Command::execute_raw into executeRobin Krahl2019-02-19
| | | | | | | The execute_raw method does not have to be part of the Command trait. In order to simplify the Command trait and to make future changes easier, we remove the execute_raw method and replace it with the execute function.
* Fix formatting in commands.rsRobin Krahl2019-02-18
|
* Use ssmarshal to convert data from and to byte slicesRobin Krahl2019-02-18
| | | | | | Previously, we manually converted the request and response data from and to byte slices. This patch adds the ssmarshal dependency that automates the serialization and deserialization in the required format.
* Refactor command execution into commands moduleRobin Krahl2019-02-18
This patch refactors the command execution. A command is represented by a struct implementing the Command trait. The enum_cmd macro is used to generate a mapping from the CommandId enum to a Command instance and to execute the command. The request and response data is manually converted from and to raw byte slices. As we do not have a standard library, we cannot create a Box<Command> from a CommandId. Instead, we directly delegate the execute method to the corresponding Command.