diff options
-rw-r--r-- | src/commands.rs | 4 | ||||
-rw-r--r-- | src/util.rs | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/commands.rs b/src/commands.rs index d05423e..99e049f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -6,7 +6,7 @@ use core::default::Default; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; -use crate::device::CommandStatus; +use crate::device::{CommandStatus, RequestData, ResponseData}; enum_cmd! { #[derive(Clone, Copy, Debug, PartialEq)] @@ -79,7 +79,7 @@ impl Command for ReadSlotNameCommand { } } -fn execute<C: Command>(data: &[u8], buf: &mut [u8]) -> CommandStatus { +fn execute<C: Command>(data: &RequestData, buf: &mut ResponseData) -> CommandStatus { // TODO: better error if (de-)serialization fails if let Ok((request, _)) = ssmarshal::deserialize::<C::Request>(data) { match C::execute(request) { diff --git a/src/util.rs b/src/util.rs index cbe7c0d..c86d047 100644 --- a/src/util.rs +++ b/src/util.rs @@ -21,7 +21,11 @@ macro_rules! enum_cmd { } impl $name { - pub fn execute(&self, data: &[u8], buf: &mut [u8]) -> CommandStatus { + pub fn execute( + &self, + data: &crate::device::RequestData, + buf: &mut crate::device::ResponseData, + ) -> CommandStatus { match *self { $( $name::$var => crate::commands::execute::<$cmd>(data, buf), |