From 853e613769087a4bf67023e42f7fc4f3b92339fb Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 20 Feb 2019 23:13:38 +0000 Subject: Split struct Crc into trait Crc and struct Stm32Crc There are different ways to implement the CRC check: For testing, we might want to calulate the CRC in the software. On STM32 MCUs, we want to use the CRC peripheral. This patch splits the struct Crc into the Crc trait and the Stm32Crc struct implementing Crc using the CRC peripheral. The Nitrokey struct can now accept any Crc implementation. --- src/device.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/device.rs') diff --git a/src/device.rs b/src/device.rs index 9f3d1a7..830fa93 100644 --- a/src/device.rs +++ b/src/device.rs @@ -94,15 +94,15 @@ impl Response { } } -pub struct Nitrokey { - crc: Crc, +pub struct Nitrokey { + crc: C, request: Option, request_crc: u32, buf: [u8; REPORT_LEN], } -impl Nitrokey { - pub fn new(crc: Crc) -> Self { +impl Nitrokey { + pub fn new(crc: C) -> Self { Nitrokey { crc, request: None, @@ -112,7 +112,7 @@ impl Nitrokey { } } -impl HidDevice for Nitrokey { +impl HidDevice for Nitrokey { fn subclass(&self) -> Subclass { Subclass::BootInterface } -- cgit v1.2.1