|
5 | 5 | use std::{cmp, fmt, io, str}; |
6 | 6 |
|
7 | 7 | use crate::consts::*; |
8 | | -use crate::util::io_err; |
9 | | - |
10 | | -pub fn to_hex(data: &[u8], joiner: &str) -> String { |
11 | | - let parts: Vec<String> = data.iter().map(|byte| format!("{:02x}", byte)).collect(); |
12 | | - parts.join(joiner) |
13 | | -} |
14 | | - |
15 | | -pub fn trace_hex(data: &[u8]) { |
16 | | - if log_enabled!(log::Level::Trace) { |
17 | | - trace!("USB send: {}", to_hex(data, "")); |
18 | | - } |
19 | | -} |
| 8 | +use crate::util::{io_err, trace_hex, to_hex}; |
20 | 9 |
|
21 | 10 | // Trait for representing U2F HID Devices. Requires getters/setters for the |
22 | 11 | // channel ID, created during device initialization. |
@@ -97,7 +86,7 @@ impl U2FHIDInit { |
97 | 86 |
|
98 | 87 | let count = cmp::min(data.len(), dev.out_init_data_size()); |
99 | 88 | frame[8..8 + count].copy_from_slice(&data[..count]); |
100 | | - trace_hex(&frame); |
| 89 | + trace_hex("USB send", &frame); |
101 | 90 |
|
102 | 91 | if dev.write(&frame)? != frame.len() { |
103 | 92 | return Err(io_err("device write failed")); |
@@ -150,7 +139,7 @@ impl U2FHIDCont { |
150 | 139 |
|
151 | 140 | let count = cmp::min(data.len(), dev.out_cont_data_size()); |
152 | 141 | frame[6..6 + count].copy_from_slice(&data[..count]); |
153 | | - trace_hex(&frame); |
| 142 | + trace_hex("USB send", &frame); |
154 | 143 |
|
155 | 144 | if dev.write(&frame)? != frame.len() { |
156 | 145 | return Err(io_err("device write failed")); |
|
0 commit comments