@@ -45,9 +45,9 @@ impl From<u32> for OsdpCardFormats {
45
45
}
46
46
}
47
47
48
- impl Into < u32 > for OsdpCardFormats {
49
- fn into ( self ) -> u32 {
50
- match self {
48
+ impl From < OsdpCardFormats > for u32 {
49
+ fn from ( val : OsdpCardFormats ) -> Self {
50
+ match val {
51
51
OsdpCardFormats :: Unspecified => {
52
52
libosdp_sys:: osdp_event_cardread_format_e_OSDP_CARD_FMT_RAW_UNSPECIFIED
53
53
}
@@ -118,7 +118,7 @@ impl OsdpEventCardRead {
118
118
119
119
impl From < libosdp_sys:: osdp_event_cardread > for OsdpEventCardRead {
120
120
fn from ( value : libosdp_sys:: osdp_event_cardread ) -> Self {
121
- let direction = if value. direction == 1 { true } else { false } ;
121
+ let direction = value. direction == 1 ;
122
122
let format = value. format . into ( ) ;
123
123
let len = value. length as usize ;
124
124
let ( nr_bits, nr_bytes) = match format {
@@ -143,9 +143,7 @@ impl From<OsdpEventCardRead> for libosdp_sys::osdp_event_cardread {
143
143
OsdpCardFormats :: Weigand => value. nr_bits as i32 ,
144
144
_ => value. data . len ( ) as i32 ,
145
145
} ;
146
- for i in 0 ..value. data . len ( ) {
147
- data[ i] = value. data [ i] ;
148
- }
146
+ data[ ..value. data . len ( ) ] . copy_from_slice ( & value. data [ ..] ) ;
149
147
libosdp_sys:: osdp_event_cardread {
150
148
reader_no : value. reader_no ,
151
149
format : value. format . clone ( ) . into ( ) ,
@@ -192,9 +190,7 @@ impl From<libosdp_sys::osdp_event_keypress> for OsdpEventKeyPress {
192
190
impl From < OsdpEventKeyPress > for libosdp_sys:: osdp_event_keypress {
193
191
fn from ( value : OsdpEventKeyPress ) -> Self {
194
192
let mut data = [ 0 ; libosdp_sys:: OSDP_EVENT_KEYPRESS_MAX_DATALEN as usize ] ;
195
- for i in 0 ..value. data . len ( ) {
196
- data[ i] = value. data [ i] ;
197
- }
193
+ data[ ..value. data . len ( ) ] . copy_from_slice ( & value. data [ ..] ) ;
198
194
libosdp_sys:: osdp_event_keypress {
199
195
reader_no : value. reader_no ,
200
196
length : value. data . len ( ) as i32 ,
@@ -233,9 +229,7 @@ impl From<libosdp_sys::osdp_event_mfgrep> for OsdpEventMfgReply {
233
229
impl From < OsdpEventMfgReply > for libosdp_sys:: osdp_event_mfgrep {
234
230
fn from ( value : OsdpEventMfgReply ) -> Self {
235
231
let mut data = [ 0 ; libosdp_sys:: OSDP_EVENT_MFGREP_MAX_DATALEN as usize ] ;
236
- for i in 0 ..value. data . len ( ) {
237
- data[ i] = value. data [ i] ;
238
- }
232
+ data[ ..value. data . len ( ) ] . copy_from_slice ( & value. data [ ..] ) ;
239
233
libosdp_sys:: osdp_event_mfgrep {
240
234
vendor_code : value. vendor_code . as_le ( ) ,
241
235
command : value. reply ,
@@ -282,16 +276,16 @@ impl From<OsdpStatusReportType> for u32 {
282
276
fn from ( value : OsdpStatusReportType ) -> Self {
283
277
match value {
284
278
OsdpStatusReportType :: Input => {
285
- libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_INPUT as u32
279
+ libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_INPUT
286
280
}
287
281
OsdpStatusReportType :: Output => {
288
- libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_OUTPUT as u32
282
+ libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_OUTPUT
289
283
}
290
284
OsdpStatusReportType :: Remote => {
291
- libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_REMOTE as u32
285
+ libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_REMOTE
292
286
}
293
287
OsdpStatusReportType :: Local => {
294
- libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_LOCAL as u32
288
+ libosdp_sys:: osdp_status_report_type_OSDP_STATUS_REPORT_LOCAL
295
289
}
296
290
}
297
291
}
0 commit comments