1use byteorder::{ByteOrder, LittleEndian};
3
4use crate::converting_receiver::BrickletError;
5
6pub trait ToBytes {
8 fn to_le_byte_vec(_: Self) -> Vec<u8>;
10 fn write_to_slice(self, target: &mut [u8]);
11
12 fn try_to_le_byte_vec(var: Self, _max_len: usize) -> Result<Vec<u8>, BrickletError>
18 where
19 Self: std::marker::Sized,
20 {
21 Ok(Self::to_le_byte_vec(var))
22 }
23 fn try_write_to_slice(self, _max_len: usize, target: &mut [u8]) -> Result<(), BrickletError>
24 where
25 Self: std::marker::Sized,
26 {
27 self.write_to_slice(target);
28 Ok(())
29 }
30}
31
32pub trait FromByteSlice {
34 fn from_le_byte_slice(bytes: &[u8]) -> Self;
36 fn bytes_expected() -> usize;
38}
39impl<const N: usize> FromByteSlice for Box<[u8; N]> {
40 fn from_le_byte_slice(bytes: &[u8]) -> Self {
41 assert_eq!(bytes.len(), Self::bytes_expected());
42 let mut ret = Box::new([0; N]);
43 ret.clone_from_slice(bytes);
44 ret
45 }
46
47 fn bytes_expected() -> usize {
48 N
49 }
50}
51impl<const N: usize> FromByteSlice for Box<[i16; N]> {
52 fn from_le_byte_slice(bytes: &[u8]) -> Self {
53 assert_eq!(bytes.len() * 2, Self::bytes_expected());
54 let mut ret = Box::new([0; N]);
55 for i in 0..N {
56 ret[i] = i16::from_le_byte_slice(&bytes[i * 2..i * 2 + 2]);
57 }
58 ret
59 }
60
61 fn bytes_expected() -> usize {
62 N * 2
63 }
64}
65
66impl<const N: usize> FromByteSlice for Box<[u16; N]> {
67 fn from_le_byte_slice(bytes: &[u8]) -> Self {
68 assert_eq!(bytes.len() * 2, Self::bytes_expected());
69 let mut ret = Box::new([0; N]);
70 for i in 0..N {
71 ret[i] = u16::from_le_byte_slice(&bytes[i * 2..i * 2 + 2]);
72 }
73 ret
74 }
75
76 fn bytes_expected() -> usize {
77 N * 2
78 }
79}
80
81impl<const N: usize> FromByteSlice for Box<[i32; N]> {
82 fn from_le_byte_slice(bytes: &[u8]) -> Self {
83 assert_eq!(bytes.len(), Self::bytes_expected());
84 let mut ret = Box::new([0; N]);
85 for i in 0..N {
86 ret[i] = i32::from_le_byte_slice(&bytes[i * 4..i * 4 + 4]);
87 }
88 ret
89 }
90
91 fn bytes_expected() -> usize {
92 N * 4
93 }
94}
95impl<const N: usize> FromByteSlice for Box<[i64; N]> {
96 fn from_le_byte_slice(bytes: &[u8]) -> Self {
97 assert_eq!(bytes.len(), Self::bytes_expected());
98 let mut ret = Box::new([0; N]);
99 for i in 0..N {
100 ret[i] = i64::from_le_byte_slice(&bytes[i * 8..i * 8 + 8]);
101 }
102 ret
103 }
104
105 fn bytes_expected() -> usize {
106 N * 8
107 }
108}
109impl<const N: usize> FromByteSlice for Box<[bool; N]> {
110 fn from_le_byte_slice(bytes: &[u8]) -> Self {
111 assert_eq!(bytes.len(), Self::bytes_expected());
112 let mut ret = Box::new([false; N]);
113 for (byte, elem) in bytes.into_iter().enumerate() {
114 for i in 0..8 {
115 if byte * 8 + i >= N {
116 break;
117 }
118 ret[byte * 8 + i] = (*elem & 1 << i) > 0;
119 }
120 }
121 ret
122 }
123
124 fn bytes_expected() -> usize {
125 (N + 7) / 8
126 }
127}
128impl<const N: usize> FromByteSlice for Box<[char; N]> {
129 fn from_le_byte_slice(bytes: &[u8]) -> Self {
130 assert_eq!(bytes.len(), Self::bytes_expected());
131 let mut ret = Box::new([0 as char; N]);
132 for i in 0..N {
133 ret[i] = bytes[i] as char;
134 }
135 ret
136 }
137
138 fn bytes_expected() -> usize {
139 N
140 }
141}
142impl ToBytes for () {
166 fn to_le_byte_vec(_: ()) -> Vec<u8> {
167 vec![]
168 }
169
170 fn write_to_slice(self, _target: &mut [u8]) {}
171}
172
173impl FromByteSlice for () {
174 fn from_le_byte_slice(_: &[u8]) {}
175
176 fn bytes_expected() -> usize {
177 0
178 }
179}
180
181impl ToBytes for bool {
182 fn to_le_byte_vec(b: bool) -> Vec<u8> {
183 vec![b as u8]
184 }
185
186 fn write_to_slice(self, target: &mut [u8]) {
187 *(target.get_mut(0).expect("slice too small")) = self as u8;
188 }
189}
190
191impl FromByteSlice for bool {
192 fn from_le_byte_slice(bytes: &[u8]) -> bool {
193 bytes[0] != 0
194 }
195
196 fn bytes_expected() -> usize {
197 1
198 }
199}
200
201impl ToBytes for u8 {
202 fn to_le_byte_vec(num: u8) -> Vec<u8> {
203 vec![num]
204 }
205
206 fn write_to_slice(self, target: &mut [u8]) {
207 *(target.get_mut(0).expect("slice too small")) = self;
208 }
209}
210
211impl FromByteSlice for u8 {
212 fn from_le_byte_slice(bytes: &[u8]) -> u8 {
213 bytes[0]
214 }
215
216 fn bytes_expected() -> usize {
217 1
218 }
219}
220
221impl ToBytes for i8 {
222 fn to_le_byte_vec(num: i8) -> Vec<u8> {
223 vec![num as u8]
224 }
225 fn write_to_slice(self, target: &mut [u8]) {
226 *(target.get_mut(0).expect("slice too small")) = self as u8;
227 }
228}
229
230impl FromByteSlice for i8 {
231 fn from_le_byte_slice(bytes: &[u8]) -> i8 {
232 bytes[0] as i8
233 }
234
235 fn bytes_expected() -> usize {
236 1
237 }
238}
239
240impl ToBytes for u16 {
241 fn to_le_byte_vec(num: u16) -> Vec<u8> {
242 let mut buf = vec![0; 2];
243 LittleEndian::write_u16(&mut buf, num);
244 buf
245 }
246 fn write_to_slice(self, target: &mut [u8]) {
247 LittleEndian::write_u16(target, self);
248 }
249}
250
251impl FromByteSlice for u16 {
252 fn from_le_byte_slice(bytes: &[u8]) -> u16 {
253 LittleEndian::read_u16(bytes)
254 }
255
256 fn bytes_expected() -> usize {
257 2
258 }
259}
260
261impl ToBytes for i16 {
262 fn to_le_byte_vec(num: i16) -> Vec<u8> {
263 let mut buf = vec![0; 2];
264 LittleEndian::write_i16(&mut buf, num);
265 buf
266 }
267
268 fn write_to_slice(self, target: &mut [u8]) {
269 LittleEndian::write_i16(target, self);
270 }
271}
272
273impl FromByteSlice for i16 {
274 fn from_le_byte_slice(bytes: &[u8]) -> i16 {
275 LittleEndian::read_i16(bytes)
276 }
277
278 fn bytes_expected() -> usize {
279 2
280 }
281}
282
283impl ToBytes for u32 {
284 fn to_le_byte_vec(num: u32) -> Vec<u8> {
285 let mut buf = vec![0; 4];
286 LittleEndian::write_u32(&mut buf, num);
287 buf
288 }
289
290 fn write_to_slice(self, target: &mut [u8]) {
291 LittleEndian::write_u32(target, self);
292 }
293}
294
295impl FromByteSlice for u32 {
296 fn from_le_byte_slice(bytes: &[u8]) -> u32 {
297 LittleEndian::read_u32(bytes)
298 }
299
300 fn bytes_expected() -> usize {
301 4
302 }
303}
304
305impl ToBytes for i32 {
306 fn to_le_byte_vec(num: i32) -> Vec<u8> {
307 let mut buf = vec![0; 4];
308 LittleEndian::write_i32(&mut buf, num);
309 buf
310 }
311
312 fn write_to_slice(self, target: &mut [u8]) {
313 LittleEndian::write_i32(target, self);
314 }
315}
316
317impl FromByteSlice for i32 {
318 fn from_le_byte_slice(bytes: &[u8]) -> i32 {
319 LittleEndian::read_i32(bytes)
320 }
321
322 fn bytes_expected() -> usize {
323 4
324 }
325}
326
327impl ToBytes for u64 {
328 fn to_le_byte_vec(num: u64) -> Vec<u8> {
329 let mut buf = vec![0; 8];
330 LittleEndian::write_u64(&mut buf, num);
331 buf
332 }
333
334 fn write_to_slice(self, target: &mut [u8]) {
335 LittleEndian::write_u64(target, self);
336 }
337}
338
339impl FromByteSlice for u64 {
340 fn from_le_byte_slice(bytes: &[u8]) -> u64 {
341 LittleEndian::read_u64(bytes)
342 }
343
344 fn bytes_expected() -> usize {
345 8
346 }
347}
348
349impl ToBytes for i64 {
350 fn to_le_byte_vec(num: i64) -> Vec<u8> {
351 let mut buf = vec![0; 8];
352 LittleEndian::write_i64(&mut buf, num);
353 buf
354 }
355
356 fn write_to_slice(self, target: &mut [u8]) {
357 LittleEndian::write_i64(target, self);
358 }
359}
360
361impl FromByteSlice for i64 {
362 fn from_le_byte_slice(bytes: &[u8]) -> i64 {
363 LittleEndian::read_i64(bytes)
364 }
365
366 fn bytes_expected() -> usize {
367 8
368 }
369}
370
371impl ToBytes for char {
372 fn to_le_byte_vec(c: char) -> Vec<u8> {
373 vec![c as u8]
374 }
375
376 fn write_to_slice(self, target: &mut [u8]) {
377 *(target.get_mut(0).expect("slice too small")) = self as u8;
378 }
379}
380
381impl FromByteSlice for char {
382 fn from_le_byte_slice(bytes: &[u8]) -> char {
383 bytes[0] as char
384 }
385
386 fn bytes_expected() -> usize {
387 1
388 }
389}
390
391impl ToBytes for String {
392 fn to_le_byte_vec(s: String) -> Vec<u8> {
393 s.into_bytes()
394 }
395
396 fn write_to_slice(self, target: &mut [u8]) {
397 target.copy_from_slice(&self.into_bytes());
398 }
399
400 fn try_to_le_byte_vec(s: String, max_len: usize) -> Result<Vec<u8>, BrickletError> {
401 if s.chars().any(|c| c as u32 > 255) {
402 return Err(BrickletError::InvalidParameter);
403 }
404 let bytes: Vec<u8> = s.chars().map(|c| c as u8).collect();
405 if bytes.len() > max_len {
406 Err(BrickletError::InvalidParameter)
407 } else {
408 let mut result = vec![0u8; max_len];
409 result[0..bytes.len()].copy_from_slice(&bytes);
410 Ok(result)
411 }
412 }
413
414 fn try_write_to_slice(self, max_len: usize, target: &mut [u8]) -> Result<(), BrickletError>
415 where
416 Self: Sized,
417 {
418 let bytes = self.into_bytes();
419 if bytes.len() > max_len {
420 Err(BrickletError::InvalidParameter)
421 } else {
422 target[0..bytes.len()].copy_from_slice(&bytes);
423 Ok(())
424 }
425 }
426}
427
428impl FromByteSlice for String {
429 fn from_le_byte_slice(bytes: &[u8]) -> String {
430 bytes.into_iter().filter(|&&b| b != 0).map(|&b| b as char).collect()
431 }
432
433 fn bytes_expected() -> usize {
434 1
435 }
436}
437
438impl ToBytes for f32 {
439 fn to_le_byte_vec(num: f32) -> Vec<u8> {
440 let mut buf = vec![0; 4];
441 LittleEndian::write_f32(&mut buf, num);
442 buf
443 }
444
445 fn write_to_slice(self, target: &mut [u8]) {
446 LittleEndian::write_f32(target, self);
447 }
448}
449
450impl FromByteSlice for f32 {
451 fn from_le_byte_slice(bytes: &[u8]) -> f32 {
452 LittleEndian::read_f32(bytes)
453 }
454
455 fn bytes_expected() -> usize {
456 4
457 }
458}
459
460impl ToBytes for f64 {
461 fn to_le_byte_vec(num: f64) -> Vec<u8> {
462 let mut buf = vec![0; 8];
463 LittleEndian::write_f64(&mut buf, num);
464 buf
465 }
466
467 fn write_to_slice(self, target: &mut [u8]) {
468 LittleEndian::write_f64(target, self);
469 }
470}
471
472impl FromByteSlice for f64 {
473 fn from_le_byte_slice(bytes: &[u8]) -> f64 {
474 LittleEndian::read_f64(bytes)
475 }
476
477 fn bytes_expected() -> usize {
478 8
479 }
480}
481
482impl ToBytes for [bool; 2] {
483 fn to_le_byte_vec(arr: [bool; 2]) -> Vec<u8> {
484 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
485 for (i, b) in arr.into_iter().enumerate() {
486 buf[i / 8] |= (*b as u8) << (i % 8);
487 }
488 buf
489 }
490 fn write_to_slice(self, target: &mut [u8]) {
491 for (i, b) in self.into_iter().enumerate() {
492 target[i / 8] |= (*b as u8) << (i % 8);
493 }
494 }
495}
496
497impl FromByteSlice for [bool; 2] {
498 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 2] {
499 let mut result = [false; 2];
500 for (byte, elem) in bytes.into_iter().enumerate() {
501 for i in 0..8 {
502 if byte * 8 + i >= result.len() {
503 break;
504 }
505 result[byte * 8 + i] = (*elem & 1 << i) > 0;
506 }
507 }
508 result
509 }
510 fn bytes_expected() -> usize {
511 1
512 }
513}
514
515impl ToBytes for [bool; 3] {
516 fn to_le_byte_vec(arr: [bool; 3]) -> Vec<u8> {
517 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
518 for (i, b) in arr.into_iter().enumerate() {
519 buf[i / 8] |= (*b as u8) << (i % 8);
520 }
521 buf
522 }
523 fn write_to_slice(self, target: &mut [u8]) {
524 for (i, b) in self.into_iter().enumerate() {
525 target[i / 8] |= (*b as u8) << (i % 8);
526 }
527 }
528}
529
530impl FromByteSlice for [bool; 3] {
531 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 3] {
532 let mut result = [false; 3];
533 for (byte, elem) in bytes.into_iter().enumerate() {
534 for i in 0..8 {
535 if byte * 8 + i >= result.len() {
536 break;
537 }
538 result[byte * 8 + i] = (*elem & 1 << i) > 0;
539 }
540 }
541 result
542 }
543 fn bytes_expected() -> usize {
544 1
545 }
546}
547
548impl ToBytes for [bool; 4] {
549 fn to_le_byte_vec(arr: [bool; 4]) -> Vec<u8> {
550 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
551 for (i, b) in arr.into_iter().enumerate() {
552 buf[i / 8] |= (*b as u8) << (i % 8);
553 }
554 buf
555 }
556 fn write_to_slice(self, target: &mut [u8]) {
557 for (i, b) in self.into_iter().enumerate() {
558 target[i / 8] |= (*b as u8) << (i % 8);
559 }
560 }
561}
562
563impl FromByteSlice for [bool; 4] {
564 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 4] {
565 let mut result = [false; 4];
566 for (byte, elem) in bytes.into_iter().enumerate() {
567 for i in 0..8 {
568 if byte * 8 + i >= result.len() {
569 break;
570 }
571 result[byte * 8 + i] = (*elem & 1 << i) > 0;
572 }
573 }
574 result
575 }
576 fn bytes_expected() -> usize {
577 1
578 }
579}
580
581impl ToBytes for [bool; 5] {
582 fn to_le_byte_vec(arr: [bool; 5]) -> Vec<u8> {
583 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
584 for (i, b) in arr.into_iter().enumerate() {
585 buf[i / 8] |= (*b as u8) << (i % 8);
586 }
587 buf
588 }
589 fn write_to_slice(self, target: &mut [u8]) {
590 for (i, b) in self.into_iter().enumerate() {
591 target[i / 8] |= (*b as u8) << (i % 8);
592 }
593 }
594}
595
596impl FromByteSlice for [bool; 5] {
597 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 5] {
598 let mut result = [false; 5];
599 for (byte, elem) in bytes.into_iter().enumerate() {
600 for i in 0..8 {
601 if byte * 8 + i >= result.len() {
602 break;
603 }
604 result[byte * 8 + i] = (*elem & 1 << i) > 0;
605 }
606 }
607 result
608 }
609 fn bytes_expected() -> usize {
610 1
611 }
612}
613
614impl ToBytes for [bool; 8] {
615 fn to_le_byte_vec(arr: [bool; 8]) -> Vec<u8> {
616 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
617 for (i, b) in arr.into_iter().enumerate() {
618 buf[i / 8] |= (*b as u8) << (i % 8);
619 }
620 buf
621 }
622 fn write_to_slice(self, target: &mut [u8]) {
623 for (i, b) in self.into_iter().enumerate() {
624 target[i / 8] |= (*b as u8) << (i % 8);
625 }
626 }
627}
628
629impl FromByteSlice for [bool; 8] {
630 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 8] {
631 let mut result = [false; 8];
632 for (byte, elem) in bytes.into_iter().enumerate() {
633 for i in 0..8 {
634 if byte * 8 + i >= result.len() {
635 break;
636 }
637 result[byte * 8 + i] = (*elem & 1 << i) > 0;
638 }
639 }
640 result
641 }
642 fn bytes_expected() -> usize {
643 1
644 }
645}
646
647impl ToBytes for [bool; 10] {
648 fn to_le_byte_vec(arr: [bool; 10]) -> Vec<u8> {
649 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
650 for (i, b) in arr.into_iter().enumerate() {
651 buf[i / 8] |= (*b as u8) << (i % 8);
652 }
653 buf
654 }
655 fn write_to_slice(self, target: &mut [u8]) {
656 for (i, b) in self.into_iter().enumerate() {
657 target[i / 8] |= (*b as u8) << (i % 8);
658 }
659 }
660}
661
662impl FromByteSlice for [bool; 10] {
663 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 10] {
664 let mut result = [false; 10];
665 for (byte, elem) in bytes.into_iter().enumerate() {
666 for i in 0..8 {
667 if byte * 8 + i >= result.len() {
668 break;
669 }
670 result[byte * 8 + i] = (*elem & 1 << i) > 0;
671 }
672 }
673 result
674 }
675 fn bytes_expected() -> usize {
676 2
677 }
678}
679
680impl ToBytes for [bool; 13] {
681 fn to_le_byte_vec(arr: [bool; 13]) -> Vec<u8> {
682 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
683 for (i, b) in arr.into_iter().enumerate() {
684 buf[i / 8] |= (*b as u8) << (i % 8);
685 }
686 buf
687 }
688 fn write_to_slice(self, target: &mut [u8]) {
689 for (i, b) in self.into_iter().enumerate() {
690 target[i / 8] |= (*b as u8) << (i % 8);
691 }
692 }
693}
694
695impl FromByteSlice for [bool; 13] {
696 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 13] {
697 let mut result = [false; 13];
698 for (byte, elem) in bytes.into_iter().enumerate() {
699 for i in 0..8 {
700 if byte * 8 + i >= result.len() {
701 break;
702 }
703 result[byte * 8 + i] = (*elem & 1 << i) > 0;
704 }
705 }
706 result
707 }
708 fn bytes_expected() -> usize {
709 2
710 }
711}
712
713impl ToBytes for [bool; 16] {
714 fn to_le_byte_vec(arr: [bool; 16]) -> Vec<u8> {
715 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
716 for (i, b) in arr.into_iter().enumerate() {
717 buf[i / 8] |= (*b as u8) << (i % 8);
718 }
719 buf
720 }
721 fn write_to_slice(self, target: &mut [u8]) {
722 for (i, b) in self.into_iter().enumerate() {
723 target[i / 8] |= (*b as u8) << (i % 8);
724 }
725 }
726}
727
728impl FromByteSlice for [bool; 16] {
729 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 16] {
730 let mut result = [false; 16];
731 for (byte, elem) in bytes.into_iter().enumerate() {
732 for i in 0..8 {
733 if byte * 8 + i >= result.len() {
734 break;
735 }
736 result[byte * 8 + i] = (*elem & 1 << i) > 0;
737 }
738 }
739 result
740 }
741 fn bytes_expected() -> usize {
742 2
743 }
744}
745
746impl ToBytes for [bool; 24] {
747 fn to_le_byte_vec(arr: [bool; 24]) -> Vec<u8> {
748 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
749 for (i, b) in arr.into_iter().enumerate() {
750 buf[i / 8] |= (*b as u8) << (i % 8);
751 }
752 buf
753 }
754 fn write_to_slice(self, target: &mut [u8]) {
755 for (i, b) in self.into_iter().enumerate() {
756 target[i / 8] |= (*b as u8) << (i % 8);
757 }
758 }
759}
760
761impl FromByteSlice for [bool; 24] {
762 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 24] {
763 let mut result = [false; 24];
764 for (byte, elem) in bytes.into_iter().enumerate() {
765 for i in 0..8 {
766 if byte * 8 + i >= result.len() {
767 break;
768 }
769 result[byte * 8 + i] = (*elem & 1 << i) > 0;
770 }
771 }
772 result
773 }
774 fn bytes_expected() -> usize {
775 3
776 }
777}
778
779impl ToBytes for [bool; 32] {
780 fn to_le_byte_vec(arr: [bool; 32]) -> Vec<u8> {
781 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
782 for (i, b) in arr.into_iter().enumerate() {
783 buf[i / 8] |= (*b as u8) << (i % 8);
784 }
785 buf
786 }
787 fn write_to_slice(self, target: &mut [u8]) {
788 for (i, b) in self.into_iter().enumerate() {
789 target[i / 8] |= (*b as u8) << (i % 8);
790 }
791 }
792}
793
794impl FromByteSlice for [bool; 32] {
795 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 32] {
796 let mut result = [false; 32];
797 for (byte, elem) in bytes.into_iter().enumerate() {
798 for i in 0..8 {
799 if byte * 8 + i >= result.len() {
800 break;
801 }
802 result[byte * 8 + i] = (*elem & 1 << i) > 0;
803 }
804 }
805 result
806 }
807 fn bytes_expected() -> usize {
808 4
809 }
810}
811
812impl ToBytes for [bool; 168] {
813 fn to_le_byte_vec(arr: [bool; 168]) -> Vec<u8> {
814 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
815 for (i, b) in arr.into_iter().enumerate() {
816 buf[i / 8] |= (*b as u8) << (i % 8);
817 }
818 buf
819 }
820 fn write_to_slice(self, target: &mut [u8]) {
821 for (i, b) in self.into_iter().enumerate() {
822 target[i / 8] |= (*b as u8) << (i % 8);
823 }
824 }
825}
826
827impl FromByteSlice for [bool; 168] {
828 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 168] {
829 let mut result = [false; 168];
830 for (byte, elem) in bytes.into_iter().enumerate() {
831 for i in 0..8 {
832 if byte * 8 + i >= result.len() {
833 break;
834 }
835 result[byte * 8 + i] = (*elem & 1 << i) > 0;
836 }
837 }
838 result
839 }
840 fn bytes_expected() -> usize {
841 21
842 }
843}
844
845impl ToBytes for [bool; 432] {
846 fn to_le_byte_vec(arr: [bool; 432]) -> Vec<u8> {
847 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
848 for (i, b) in arr.into_iter().enumerate() {
849 buf[i / 8] |= (*b as u8) << (i % 8);
850 }
851 buf
852 }
853 fn write_to_slice(self, target: &mut [u8]) {
854 for (i, b) in self.into_iter().enumerate() {
855 target[i / 8] |= (*b as u8) << (i % 8);
856 }
857 }
858}
859
860impl FromByteSlice for [bool; 432] {
861 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 432] {
862 let mut result = [false; 432];
863 for (byte, elem) in bytes.into_iter().enumerate() {
864 for i in 0..8 {
865 if byte * 8 + i >= result.len() {
866 break;
867 }
868 result[byte * 8 + i] = (*elem & 1 << i) > 0;
869 }
870 }
871 result
872 }
873 fn bytes_expected() -> usize {
874 54
875 }
876}
877
878impl ToBytes for [bool; 440] {
879 fn to_le_byte_vec(arr: [bool; 440]) -> Vec<u8> {
880 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
881 for (i, b) in arr.into_iter().enumerate() {
882 buf[i / 8] |= (*b as u8) << (i % 8);
883 }
884 buf
885 }
886 fn write_to_slice(self, target: &mut [u8]) {
887 for (i, b) in self.into_iter().enumerate() {
888 target[i / 8] |= (*b as u8) << (i % 8);
889 }
890 }
891}
892
893impl FromByteSlice for [bool; 440] {
894 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 440] {
895 let mut result = [false; 440];
896 for (byte, elem) in bytes.into_iter().enumerate() {
897 for i in 0..8 {
898 if byte * 8 + i >= result.len() {
899 break;
900 }
901 result[byte * 8 + i] = (*elem & 1 << i) > 0;
902 }
903 }
904 result
905 }
906 fn bytes_expected() -> usize {
907 55
908 }
909}
910
911impl ToBytes for [bool; 448] {
912 fn to_le_byte_vec(arr: [bool; 448]) -> Vec<u8> {
913 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
914 for (i, b) in arr.into_iter().enumerate() {
915 buf[i / 8] |= (*b as u8) << (i % 8);
916 }
917 buf
918 }
919 fn write_to_slice(self, target: &mut [u8]) {
920 for (i, b) in self.into_iter().enumerate() {
921 target[i / 8] |= (*b as u8) << (i % 8);
922 }
923 }
924}
925
926impl FromByteSlice for [bool; 448] {
927 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 448] {
928 let mut result = [false; 448];
929 for (byte, elem) in bytes.into_iter().enumerate() {
930 for i in 0..8 {
931 if byte * 8 + i >= result.len() {
932 break;
933 }
934 result[byte * 8 + i] = (*elem & 1 << i) > 0;
935 }
936 }
937 result
938 }
939 fn bytes_expected() -> usize {
940 56
941 }
942}
943
944impl ToBytes for [bool; 464] {
945 fn to_le_byte_vec(arr: [bool; 464]) -> Vec<u8> {
946 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
947 for (i, b) in arr.into_iter().enumerate() {
948 buf[i / 8] |= (*b as u8) << (i % 8);
949 }
950 buf
951 }
952 fn write_to_slice(self, target: &mut [u8]) {
953 for (i, b) in self.into_iter().enumerate() {
954 target[i / 8] |= (*b as u8) << (i % 8);
955 }
956 }
957}
958
959impl FromByteSlice for [bool; 464] {
960 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 464] {
961 let mut result = [false; 464];
962 for (byte, elem) in bytes.into_iter().enumerate() {
963 for i in 0..8 {
964 if byte * 8 + i >= result.len() {
965 break;
966 }
967 result[byte * 8 + i] = (*elem & 1 << i) > 0;
968 }
969 }
970 result
971 }
972 fn bytes_expected() -> usize {
973 58
974 }
975}
976
977impl ToBytes for [bool; 472] {
978 fn to_le_byte_vec(arr: [bool; 472]) -> Vec<u8> {
979 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
980 for (i, b) in arr.into_iter().enumerate() {
981 buf[i / 8] |= (*b as u8) << (i % 8);
982 }
983 buf
984 }
985 fn write_to_slice(self, target: &mut [u8]) {
986 for (i, b) in self.into_iter().enumerate() {
987 target[i / 8] |= (*b as u8) << (i % 8);
988 }
989 }
990}
991
992impl FromByteSlice for [bool; 472] {
993 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 472] {
994 let mut result = [false; 472];
995 for (byte, elem) in bytes.into_iter().enumerate() {
996 for i in 0..8 {
997 if byte * 8 + i >= result.len() {
998 break;
999 }
1000 result[byte * 8 + i] = (*elem & 1 << i) > 0;
1001 }
1002 }
1003 result
1004 }
1005 fn bytes_expected() -> usize {
1006 59
1007 }
1008}
1009
1010impl ToBytes for [bool; 480] {
1011 fn to_le_byte_vec(arr: [bool; 480]) -> Vec<u8> {
1012 let mut buf = vec![0u8; arr.len() / 8 + if arr.len() % 8 == 0 { 0 } else { 1 }];
1013 for (i, b) in arr.into_iter().enumerate() {
1014 buf[i / 8] |= (*b as u8) << (i % 8);
1015 }
1016 buf
1017 }
1018 fn write_to_slice(self, target: &mut [u8]) {
1019 for (i, b) in self.into_iter().enumerate() {
1020 target[i / 8] |= (*b as u8) << (i % 8);
1021 }
1022 }
1023}
1024
1025impl FromByteSlice for [bool; 480] {
1026 fn from_le_byte_slice(bytes: &[u8]) -> [bool; 480] {
1027 let mut result = [false; 480];
1028 for (byte, elem) in bytes.into_iter().enumerate() {
1029 for i in 0..8 {
1030 if byte * 8 + i >= result.len() {
1031 break;
1032 }
1033 result[byte * 8 + i] = (*elem & 1 << i) > 0;
1034 }
1035 }
1036 result
1037 }
1038 fn bytes_expected() -> usize {
1039 60
1040 }
1041}
1042
1043impl ToBytes for [u8; 3] {
1044 fn to_le_byte_vec(arr: [u8; 3]) -> Vec<u8> {
1045 arr.to_vec()
1046 }
1047 fn write_to_slice(self, target: &mut [u8]) {
1048 target.copy_from_slice(&self);
1049 }
1050}
1051
1052impl FromByteSlice for [u8; 3] {
1053 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 3] {
1054 let mut buf = [0u8; 3];
1055 buf.copy_from_slice(bytes);
1056 buf
1057 }
1058 fn bytes_expected() -> usize {
1059 3
1060 }
1061}
1062
1063impl ToBytes for [u8; 4] {
1064 fn to_le_byte_vec(arr: [u8; 4]) -> Vec<u8> {
1065 arr.to_vec()
1066 }
1067 fn write_to_slice(self, target: &mut [u8]) {
1068 target.copy_from_slice(&self);
1069 }
1070}
1071
1072impl FromByteSlice for [u8; 4] {
1073 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 4] {
1074 let mut buf = [0u8; 4];
1075 buf.copy_from_slice(bytes);
1076 buf
1077 }
1078 fn bytes_expected() -> usize {
1079 4
1080 }
1081}
1082
1083impl ToBytes for [u8; 6] {
1084 fn to_le_byte_vec(arr: [u8; 6]) -> Vec<u8> {
1085 arr.to_vec()
1086 }
1087 fn write_to_slice(self, target: &mut [u8]) {
1088 target.copy_from_slice(&self);
1089 }
1090}
1091
1092impl FromByteSlice for [u8; 6] {
1093 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 6] {
1094 let mut buf = [0u8; 6];
1095 buf.copy_from_slice(bytes);
1096 buf
1097 }
1098 fn bytes_expected() -> usize {
1099 6
1100 }
1101}
1102
1103impl ToBytes for [u8; 7] {
1104 fn to_le_byte_vec(arr: [u8; 7]) -> Vec<u8> {
1105 arr.to_vec()
1106 }
1107 fn write_to_slice(self, target: &mut [u8]) {
1108 target.copy_from_slice(&self);
1109 }
1110}
1111
1112impl FromByteSlice for [u8; 7] {
1113 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 7] {
1114 let mut buf = [0u8; 7];
1115 buf.copy_from_slice(bytes);
1116 buf
1117 }
1118 fn bytes_expected() -> usize {
1119 7
1120 }
1121}
1122
1123impl ToBytes for [u8; 8] {
1124 fn to_le_byte_vec(arr: [u8; 8]) -> Vec<u8> {
1125 arr.to_vec()
1126 }
1127 fn write_to_slice(self, target: &mut [u8]) {
1128 target.copy_from_slice(&self);
1129 }
1130}
1131
1132impl FromByteSlice for [u8; 8] {
1133 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 8] {
1134 let mut buf = [0u8; 8];
1135 buf.copy_from_slice(bytes);
1136 buf
1137 }
1138 fn bytes_expected() -> usize {
1139 8
1140 }
1141}
1142
1143impl ToBytes for [u8; 10] {
1144 fn to_le_byte_vec(arr: [u8; 10]) -> Vec<u8> {
1145 arr.to_vec()
1146 }
1147 fn write_to_slice(self, target: &mut [u8]) {
1148 target.copy_from_slice(&self);
1149 }
1150}
1151
1152impl FromByteSlice for [u8; 10] {
1153 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 10] {
1154 let mut buf = [0u8; 10];
1155 buf.copy_from_slice(bytes);
1156 buf
1157 }
1158 fn bytes_expected() -> usize {
1159 10
1160 }
1161}
1162
1163impl ToBytes for [u8; 12] {
1164 fn to_le_byte_vec(arr: [u8; 12]) -> Vec<u8> {
1165 arr.to_vec()
1166 }
1167 fn write_to_slice(self, target: &mut [u8]) {
1168 target.copy_from_slice(&self);
1169 }
1170}
1171
1172impl FromByteSlice for [u8; 12] {
1173 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 12] {
1174 let mut buf = [0u8; 12];
1175 buf.copy_from_slice(bytes);
1176 buf
1177 }
1178 fn bytes_expected() -> usize {
1179 12
1180 }
1181}
1182
1183impl ToBytes for [u8; 15] {
1184 fn to_le_byte_vec(arr: [u8; 15]) -> Vec<u8> {
1185 arr.to_vec()
1186 }
1187 fn write_to_slice(self, target: &mut [u8]) {
1188 target.copy_from_slice(&self);
1189 }
1190}
1191
1192impl FromByteSlice for [u8; 15] {
1193 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 15] {
1194 let mut buf = [0u8; 15];
1195 buf.copy_from_slice(bytes);
1196 buf
1197 }
1198 fn bytes_expected() -> usize {
1199 15
1200 }
1201}
1202
1203impl ToBytes for [u8; 16] {
1204 fn to_le_byte_vec(arr: [u8; 16]) -> Vec<u8> {
1205 arr.to_vec()
1206 }
1207 fn write_to_slice(self, target: &mut [u8]) {
1208 target.copy_from_slice(&self);
1209 }
1210}
1211
1212impl FromByteSlice for [u8; 16] {
1213 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 16] {
1214 let mut buf = [0u8; 16];
1215 buf.copy_from_slice(bytes);
1216 buf
1217 }
1218 fn bytes_expected() -> usize {
1219 16
1220 }
1221}
1222
1223impl ToBytes for [u8; 20] {
1224 fn to_le_byte_vec(arr: [u8; 20]) -> Vec<u8> {
1225 arr.to_vec()
1226 }
1227 fn write_to_slice(self, target: &mut [u8]) {
1228 target.copy_from_slice(&self);
1229 }
1230}
1231
1232impl FromByteSlice for [u8; 20] {
1233 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 20] {
1234 let mut buf = [0u8; 20];
1235 buf.copy_from_slice(bytes);
1236 buf
1237 }
1238 fn bytes_expected() -> usize {
1239 20
1240 }
1241}
1242
1243impl ToBytes for [u8; 32] {
1244 fn to_le_byte_vec(arr: [u8; 32]) -> Vec<u8> {
1245 arr.to_vec()
1246 }
1247 fn write_to_slice(self, target: &mut [u8]) {
1248 target.copy_from_slice(&self);
1249 }
1250}
1251
1252impl FromByteSlice for [u8; 32] {
1253 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 32] {
1254 let mut buf = [0u8; 32];
1255 buf.copy_from_slice(bytes);
1256 buf
1257 }
1258 fn bytes_expected() -> usize {
1259 32
1260 }
1261}
1262
1263impl ToBytes for [u8; 52] {
1264 fn to_le_byte_vec(arr: [u8; 52]) -> Vec<u8> {
1265 arr.to_vec()
1266 }
1267 fn write_to_slice(self, target: &mut [u8]) {
1268 target.copy_from_slice(&self);
1269 }
1270}
1271
1272impl FromByteSlice for [u8; 52] {
1273 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 52] {
1274 let mut buf = [0u8; 52];
1275 buf.copy_from_slice(bytes);
1276 buf
1277 }
1278 fn bytes_expected() -> usize {
1279 52
1280 }
1281}
1282
1283impl ToBytes for [u8; 56] {
1284 fn to_le_byte_vec(arr: [u8; 56]) -> Vec<u8> {
1285 arr.to_vec()
1286 }
1287 fn write_to_slice(self, target: &mut [u8]) {
1288 target.copy_from_slice(&self);
1289 }
1290}
1291
1292impl FromByteSlice for [u8; 56] {
1293 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 56] {
1294 let mut buf = [0u8; 56];
1295 buf.copy_from_slice(bytes);
1296 buf
1297 }
1298 fn bytes_expected() -> usize {
1299 56
1300 }
1301}
1302
1303impl ToBytes for [u8; 58] {
1304 fn to_le_byte_vec(arr: [u8; 58]) -> Vec<u8> {
1305 arr.to_vec()
1306 }
1307 fn write_to_slice(self, target: &mut [u8]) {
1308 target.copy_from_slice(&self);
1309 }
1310}
1311
1312impl FromByteSlice for [u8; 58] {
1313 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 58] {
1314 let mut buf = [0u8; 58];
1315 buf.copy_from_slice(bytes);
1316 buf
1317 }
1318 fn bytes_expected() -> usize {
1319 58
1320 }
1321}
1322
1323impl ToBytes for [u8; 59] {
1324 fn to_le_byte_vec(arr: [u8; 59]) -> Vec<u8> {
1325 arr.to_vec()
1326 }
1327 fn write_to_slice(self, target: &mut [u8]) {
1328 target.copy_from_slice(&self);
1329 }
1330}
1331
1332impl FromByteSlice for [u8; 59] {
1333 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 59] {
1334 let mut buf = [0u8; 59];
1335 buf.copy_from_slice(bytes);
1336 buf
1337 }
1338 fn bytes_expected() -> usize {
1339 59
1340 }
1341}
1342
1343impl ToBytes for [u8; 60] {
1344 fn to_le_byte_vec(arr: [u8; 60]) -> Vec<u8> {
1345 arr.to_vec()
1346 }
1347 fn write_to_slice(self, target: &mut [u8]) {
1348 target.copy_from_slice(&self);
1349 }
1350}
1351
1352impl FromByteSlice for [u8; 60] {
1353 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 60] {
1354 let mut buf = [0u8; 60];
1355 buf.copy_from_slice(bytes);
1356 buf
1357 }
1358 fn bytes_expected() -> usize {
1359 60
1360 }
1361}
1362
1363impl ToBytes for [u8; 61] {
1364 fn to_le_byte_vec(arr: [u8; 61]) -> Vec<u8> {
1365 arr.to_vec()
1366 }
1367 fn write_to_slice(self, target: &mut [u8]) {
1368 target.copy_from_slice(&self);
1369 }
1370}
1371
1372impl FromByteSlice for [u8; 61] {
1373 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 61] {
1374 let mut buf = [0u8; 61];
1375 buf.copy_from_slice(bytes);
1376 buf
1377 }
1378 fn bytes_expected() -> usize {
1379 61
1380 }
1381}
1382
1383impl ToBytes for [u8; 62] {
1384 fn to_le_byte_vec(arr: [u8; 62]) -> Vec<u8> {
1385 arr.to_vec()
1386 }
1387 fn write_to_slice(self, target: &mut [u8]) {
1388 target.copy_from_slice(&self);
1389 }
1390}
1391
1392impl FromByteSlice for [u8; 62] {
1393 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 62] {
1394 let mut buf = [0u8; 62];
1395 buf.copy_from_slice(bytes);
1396 buf
1397 }
1398 fn bytes_expected() -> usize {
1399 62
1400 }
1401}
1402
1403impl ToBytes for [u8; 63] {
1404 fn to_le_byte_vec(arr: [u8; 63]) -> Vec<u8> {
1405 arr.to_vec()
1406 }
1407 fn write_to_slice(self, target: &mut [u8]) {
1408 target.copy_from_slice(&self);
1409 }
1410}
1411
1412impl FromByteSlice for [u8; 63] {
1413 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 63] {
1414 let mut buf = [0u8; 63];
1415 buf.copy_from_slice(bytes);
1416 buf
1417 }
1418 fn bytes_expected() -> usize {
1419 63
1420 }
1421}
1422
1423impl ToBytes for [u8; 64] {
1424 fn to_le_byte_vec(arr: [u8; 64]) -> Vec<u8> {
1425 arr.to_vec()
1426 }
1427 fn write_to_slice(self, target: &mut [u8]) {
1428 target.copy_from_slice(&self);
1429 }
1430}
1431
1432impl FromByteSlice for [u8; 64] {
1433 fn from_le_byte_slice(bytes: &[u8]) -> [u8; 64] {
1434 let mut buf = [0u8; 64];
1435 buf.copy_from_slice(bytes);
1436 buf
1437 }
1438 fn bytes_expected() -> usize {
1439 64
1440 }
1441}
1442
1443impl ToBytes for [i8; 4] {
1444 fn to_le_byte_vec(arr: [i8; 4]) -> Vec<u8> {
1445 vec![arr[0] as u8, arr[1] as u8, arr[2] as u8, arr[3] as u8]
1446 }
1447 fn write_to_slice(self, target: &mut [u8]) {
1448 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
1449 }
1450}
1451
1452impl FromByteSlice for [i8; 4] {
1453 fn from_le_byte_slice(bytes: &[u8]) -> [i8; 4] {
1454 [bytes[0] as i8, bytes[1] as i8, bytes[2] as i8, bytes[3] as i8]
1455 }
1456 fn bytes_expected() -> usize {
1457 4
1458 }
1459}
1460
1461impl ToBytes for [char; 4] {
1462 fn to_le_byte_vec(arr: [char; 4]) -> Vec<u8> {
1463 vec![arr[0] as u8, arr[1] as u8, arr[2] as u8, arr[3] as u8]
1464 }
1465 fn write_to_slice(self, target: &mut [u8]) {
1466 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
1467 }
1468}
1469
1470impl FromByteSlice for [char; 4] {
1471 fn from_le_byte_slice(bytes: &[u8]) -> [char; 4] {
1472 [bytes[0] as char, bytes[1] as char, bytes[2] as char, bytes[3] as char]
1473 }
1474 fn bytes_expected() -> usize {
1475 4
1476 }
1477}
1478
1479impl ToBytes for [char; 5] {
1480 fn to_le_byte_vec(arr: [char; 5]) -> Vec<u8> {
1481 vec![arr[0] as u8, arr[1] as u8, arr[2] as u8, arr[3] as u8, arr[4] as u8]
1482 }
1483 fn write_to_slice(self, target: &mut [u8]) {
1484 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
1485 }
1486}
1487
1488impl FromByteSlice for [char; 5] {
1489 fn from_le_byte_slice(bytes: &[u8]) -> [char; 5] {
1490 [bytes[0] as char, bytes[1] as char, bytes[2] as char, bytes[3] as char, bytes[4] as char]
1491 }
1492 fn bytes_expected() -> usize {
1493 5
1494 }
1495}
1496
1497impl ToBytes for [i8; 32] {
1498 fn to_le_byte_vec(arr: [i8; 32]) -> Vec<u8> {
1499 vec![
1500 arr[0] as u8,
1501 arr[1] as u8,
1502 arr[2] as u8,
1503 arr[3] as u8,
1504 arr[4] as u8,
1505 arr[5] as u8,
1506 arr[6] as u8,
1507 arr[7] as u8,
1508 arr[8] as u8,
1509 arr[9] as u8,
1510 arr[10] as u8,
1511 arr[11] as u8,
1512 arr[12] as u8,
1513 arr[13] as u8,
1514 arr[14] as u8,
1515 arr[15] as u8,
1516 arr[16] as u8,
1517 arr[17] as u8,
1518 arr[18] as u8,
1519 arr[19] as u8,
1520 arr[20] as u8,
1521 arr[21] as u8,
1522 arr[22] as u8,
1523 arr[23] as u8,
1524 arr[24] as u8,
1525 arr[25] as u8,
1526 arr[26] as u8,
1527 arr[27] as u8,
1528 arr[28] as u8,
1529 arr[29] as u8,
1530 arr[30] as u8,
1531 arr[31] as u8,
1532 ]
1533 }
1534 fn write_to_slice(self, target: &mut [u8]) {
1535 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
1536 }
1537}
1538
1539impl FromByteSlice for [i8; 32] {
1540 fn from_le_byte_slice(bytes: &[u8]) -> [i8; 32] {
1541 [
1542 bytes[0] as i8,
1543 bytes[1] as i8,
1544 bytes[2] as i8,
1545 bytes[3] as i8,
1546 bytes[4] as i8,
1547 bytes[5] as i8,
1548 bytes[6] as i8,
1549 bytes[7] as i8,
1550 bytes[8] as i8,
1551 bytes[9] as i8,
1552 bytes[10] as i8,
1553 bytes[11] as i8,
1554 bytes[12] as i8,
1555 bytes[13] as i8,
1556 bytes[14] as i8,
1557 bytes[15] as i8,
1558 bytes[16] as i8,
1559 bytes[17] as i8,
1560 bytes[18] as i8,
1561 bytes[19] as i8,
1562 bytes[20] as i8,
1563 bytes[21] as i8,
1564 bytes[22] as i8,
1565 bytes[23] as i8,
1566 bytes[24] as i8,
1567 bytes[25] as i8,
1568 bytes[26] as i8,
1569 bytes[27] as i8,
1570 bytes[28] as i8,
1571 bytes[29] as i8,
1572 bytes[30] as i8,
1573 bytes[31] as i8,
1574 ]
1575 }
1576 fn bytes_expected() -> usize {
1577 32
1578 }
1579}
1580
1581impl ToBytes for [char; 56] {
1582 fn to_le_byte_vec(arr: [char; 56]) -> Vec<u8> {
1583 vec![
1584 arr[0] as u8,
1585 arr[1] as u8,
1586 arr[2] as u8,
1587 arr[3] as u8,
1588 arr[4] as u8,
1589 arr[5] as u8,
1590 arr[6] as u8,
1591 arr[7] as u8,
1592 arr[8] as u8,
1593 arr[9] as u8,
1594 arr[10] as u8,
1595 arr[11] as u8,
1596 arr[12] as u8,
1597 arr[13] as u8,
1598 arr[14] as u8,
1599 arr[15] as u8,
1600 arr[16] as u8,
1601 arr[17] as u8,
1602 arr[18] as u8,
1603 arr[19] as u8,
1604 arr[20] as u8,
1605 arr[21] as u8,
1606 arr[22] as u8,
1607 arr[23] as u8,
1608 arr[24] as u8,
1609 arr[25] as u8,
1610 arr[26] as u8,
1611 arr[27] as u8,
1612 arr[28] as u8,
1613 arr[29] as u8,
1614 arr[30] as u8,
1615 arr[31] as u8,
1616 arr[32] as u8,
1617 arr[33] as u8,
1618 arr[34] as u8,
1619 arr[35] as u8,
1620 arr[36] as u8,
1621 arr[37] as u8,
1622 arr[38] as u8,
1623 arr[39] as u8,
1624 arr[40] as u8,
1625 arr[41] as u8,
1626 arr[42] as u8,
1627 arr[43] as u8,
1628 arr[44] as u8,
1629 arr[45] as u8,
1630 arr[46] as u8,
1631 arr[47] as u8,
1632 arr[48] as u8,
1633 arr[49] as u8,
1634 arr[50] as u8,
1635 arr[51] as u8,
1636 arr[52] as u8,
1637 arr[53] as u8,
1638 arr[54] as u8,
1639 arr[55] as u8,
1640 ]
1641 }
1642 fn write_to_slice(self, target: &mut [u8]) {
1643 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
1644 }
1645}
1646
1647impl FromByteSlice for [char; 56] {
1648 fn from_le_byte_slice(bytes: &[u8]) -> [char; 56] {
1649 [
1650 bytes[0] as char,
1651 bytes[1] as char,
1652 bytes[2] as char,
1653 bytes[3] as char,
1654 bytes[4] as char,
1655 bytes[5] as char,
1656 bytes[6] as char,
1657 bytes[7] as char,
1658 bytes[8] as char,
1659 bytes[9] as char,
1660 bytes[10] as char,
1661 bytes[11] as char,
1662 bytes[12] as char,
1663 bytes[13] as char,
1664 bytes[14] as char,
1665 bytes[15] as char,
1666 bytes[16] as char,
1667 bytes[17] as char,
1668 bytes[18] as char,
1669 bytes[19] as char,
1670 bytes[20] as char,
1671 bytes[21] as char,
1672 bytes[22] as char,
1673 bytes[23] as char,
1674 bytes[24] as char,
1675 bytes[25] as char,
1676 bytes[26] as char,
1677 bytes[27] as char,
1678 bytes[28] as char,
1679 bytes[29] as char,
1680 bytes[30] as char,
1681 bytes[31] as char,
1682 bytes[32] as char,
1683 bytes[33] as char,
1684 bytes[34] as char,
1685 bytes[35] as char,
1686 bytes[36] as char,
1687 bytes[37] as char,
1688 bytes[38] as char,
1689 bytes[39] as char,
1690 bytes[40] as char,
1691 bytes[41] as char,
1692 bytes[42] as char,
1693 bytes[43] as char,
1694 bytes[44] as char,
1695 bytes[45] as char,
1696 bytes[46] as char,
1697 bytes[47] as char,
1698 bytes[48] as char,
1699 bytes[49] as char,
1700 bytes[50] as char,
1701 bytes[51] as char,
1702 bytes[52] as char,
1703 bytes[53] as char,
1704 bytes[54] as char,
1705 bytes[55] as char,
1706 ]
1707 }
1708 fn bytes_expected() -> usize {
1709 56
1710 }
1711}
1712
1713impl ToBytes for [char; 58] {
1714 fn to_le_byte_vec(arr: [char; 58]) -> Vec<u8> {
1715 vec![
1716 arr[0] as u8,
1717 arr[1] as u8,
1718 arr[2] as u8,
1719 arr[3] as u8,
1720 arr[4] as u8,
1721 arr[5] as u8,
1722 arr[6] as u8,
1723 arr[7] as u8,
1724 arr[8] as u8,
1725 arr[9] as u8,
1726 arr[10] as u8,
1727 arr[11] as u8,
1728 arr[12] as u8,
1729 arr[13] as u8,
1730 arr[14] as u8,
1731 arr[15] as u8,
1732 arr[16] as u8,
1733 arr[17] as u8,
1734 arr[18] as u8,
1735 arr[19] as u8,
1736 arr[20] as u8,
1737 arr[21] as u8,
1738 arr[22] as u8,
1739 arr[23] as u8,
1740 arr[24] as u8,
1741 arr[25] as u8,
1742 arr[26] as u8,
1743 arr[27] as u8,
1744 arr[28] as u8,
1745 arr[29] as u8,
1746 arr[30] as u8,
1747 arr[31] as u8,
1748 arr[32] as u8,
1749 arr[33] as u8,
1750 arr[34] as u8,
1751 arr[35] as u8,
1752 arr[36] as u8,
1753 arr[37] as u8,
1754 arr[38] as u8,
1755 arr[39] as u8,
1756 arr[40] as u8,
1757 arr[41] as u8,
1758 arr[42] as u8,
1759 arr[43] as u8,
1760 arr[44] as u8,
1761 arr[45] as u8,
1762 arr[46] as u8,
1763 arr[47] as u8,
1764 arr[48] as u8,
1765 arr[49] as u8,
1766 arr[50] as u8,
1767 arr[51] as u8,
1768 arr[52] as u8,
1769 arr[53] as u8,
1770 arr[54] as u8,
1771 arr[55] as u8,
1772 arr[56] as u8,
1773 arr[57] as u8,
1774 ]
1775 }
1776 fn write_to_slice(self, target: &mut [u8]) {
1777 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
1778 }
1779}
1780
1781impl FromByteSlice for [char; 58] {
1782 fn from_le_byte_slice(bytes: &[u8]) -> [char; 58] {
1783 [
1784 bytes[0] as char,
1785 bytes[1] as char,
1786 bytes[2] as char,
1787 bytes[3] as char,
1788 bytes[4] as char,
1789 bytes[5] as char,
1790 bytes[6] as char,
1791 bytes[7] as char,
1792 bytes[8] as char,
1793 bytes[9] as char,
1794 bytes[10] as char,
1795 bytes[11] as char,
1796 bytes[12] as char,
1797 bytes[13] as char,
1798 bytes[14] as char,
1799 bytes[15] as char,
1800 bytes[16] as char,
1801 bytes[17] as char,
1802 bytes[18] as char,
1803 bytes[19] as char,
1804 bytes[20] as char,
1805 bytes[21] as char,
1806 bytes[22] as char,
1807 bytes[23] as char,
1808 bytes[24] as char,
1809 bytes[25] as char,
1810 bytes[26] as char,
1811 bytes[27] as char,
1812 bytes[28] as char,
1813 bytes[29] as char,
1814 bytes[30] as char,
1815 bytes[31] as char,
1816 bytes[32] as char,
1817 bytes[33] as char,
1818 bytes[34] as char,
1819 bytes[35] as char,
1820 bytes[36] as char,
1821 bytes[37] as char,
1822 bytes[38] as char,
1823 bytes[39] as char,
1824 bytes[40] as char,
1825 bytes[41] as char,
1826 bytes[42] as char,
1827 bytes[43] as char,
1828 bytes[44] as char,
1829 bytes[45] as char,
1830 bytes[46] as char,
1831 bytes[47] as char,
1832 bytes[48] as char,
1833 bytes[49] as char,
1834 bytes[50] as char,
1835 bytes[51] as char,
1836 bytes[52] as char,
1837 bytes[53] as char,
1838 bytes[54] as char,
1839 bytes[55] as char,
1840 bytes[56] as char,
1841 bytes[57] as char,
1842 ]
1843 }
1844 fn bytes_expected() -> usize {
1845 58
1846 }
1847}
1848
1849impl ToBytes for [char; 59] {
1850 fn to_le_byte_vec(arr: [char; 59]) -> Vec<u8> {
1851 vec![
1852 arr[0] as u8,
1853 arr[1] as u8,
1854 arr[2] as u8,
1855 arr[3] as u8,
1856 arr[4] as u8,
1857 arr[5] as u8,
1858 arr[6] as u8,
1859 arr[7] as u8,
1860 arr[8] as u8,
1861 arr[9] as u8,
1862 arr[10] as u8,
1863 arr[11] as u8,
1864 arr[12] as u8,
1865 arr[13] as u8,
1866 arr[14] as u8,
1867 arr[15] as u8,
1868 arr[16] as u8,
1869 arr[17] as u8,
1870 arr[18] as u8,
1871 arr[19] as u8,
1872 arr[20] as u8,
1873 arr[21] as u8,
1874 arr[22] as u8,
1875 arr[23] as u8,
1876 arr[24] as u8,
1877 arr[25] as u8,
1878 arr[26] as u8,
1879 arr[27] as u8,
1880 arr[28] as u8,
1881 arr[29] as u8,
1882 arr[30] as u8,
1883 arr[31] as u8,
1884 arr[32] as u8,
1885 arr[33] as u8,
1886 arr[34] as u8,
1887 arr[35] as u8,
1888 arr[36] as u8,
1889 arr[37] as u8,
1890 arr[38] as u8,
1891 arr[39] as u8,
1892 arr[40] as u8,
1893 arr[41] as u8,
1894 arr[42] as u8,
1895 arr[43] as u8,
1896 arr[44] as u8,
1897 arr[45] as u8,
1898 arr[46] as u8,
1899 arr[47] as u8,
1900 arr[48] as u8,
1901 arr[49] as u8,
1902 arr[50] as u8,
1903 arr[51] as u8,
1904 arr[52] as u8,
1905 arr[53] as u8,
1906 arr[54] as u8,
1907 arr[55] as u8,
1908 arr[56] as u8,
1909 arr[57] as u8,
1910 arr[58] as u8,
1911 ]
1912 }
1913 fn write_to_slice(self, target: &mut [u8]) {
1914 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
1915 }
1916}
1917
1918impl FromByteSlice for [char; 59] {
1919 fn from_le_byte_slice(bytes: &[u8]) -> [char; 59] {
1920 [
1921 bytes[0] as char,
1922 bytes[1] as char,
1923 bytes[2] as char,
1924 bytes[3] as char,
1925 bytes[4] as char,
1926 bytes[5] as char,
1927 bytes[6] as char,
1928 bytes[7] as char,
1929 bytes[8] as char,
1930 bytes[9] as char,
1931 bytes[10] as char,
1932 bytes[11] as char,
1933 bytes[12] as char,
1934 bytes[13] as char,
1935 bytes[14] as char,
1936 bytes[15] as char,
1937 bytes[16] as char,
1938 bytes[17] as char,
1939 bytes[18] as char,
1940 bytes[19] as char,
1941 bytes[20] as char,
1942 bytes[21] as char,
1943 bytes[22] as char,
1944 bytes[23] as char,
1945 bytes[24] as char,
1946 bytes[25] as char,
1947 bytes[26] as char,
1948 bytes[27] as char,
1949 bytes[28] as char,
1950 bytes[29] as char,
1951 bytes[30] as char,
1952 bytes[31] as char,
1953 bytes[32] as char,
1954 bytes[33] as char,
1955 bytes[34] as char,
1956 bytes[35] as char,
1957 bytes[36] as char,
1958 bytes[37] as char,
1959 bytes[38] as char,
1960 bytes[39] as char,
1961 bytes[40] as char,
1962 bytes[41] as char,
1963 bytes[42] as char,
1964 bytes[43] as char,
1965 bytes[44] as char,
1966 bytes[45] as char,
1967 bytes[46] as char,
1968 bytes[47] as char,
1969 bytes[48] as char,
1970 bytes[49] as char,
1971 bytes[50] as char,
1972 bytes[51] as char,
1973 bytes[52] as char,
1974 bytes[53] as char,
1975 bytes[54] as char,
1976 bytes[55] as char,
1977 bytes[56] as char,
1978 bytes[57] as char,
1979 bytes[58] as char,
1980 ]
1981 }
1982 fn bytes_expected() -> usize {
1983 59
1984 }
1985}
1986
1987impl ToBytes for [i8; 60] {
1988 fn to_le_byte_vec(arr: [i8; 60]) -> Vec<u8> {
1989 vec![
1990 arr[0] as u8,
1991 arr[1] as u8,
1992 arr[2] as u8,
1993 arr[3] as u8,
1994 arr[4] as u8,
1995 arr[5] as u8,
1996 arr[6] as u8,
1997 arr[7] as u8,
1998 arr[8] as u8,
1999 arr[9] as u8,
2000 arr[10] as u8,
2001 arr[11] as u8,
2002 arr[12] as u8,
2003 arr[13] as u8,
2004 arr[14] as u8,
2005 arr[15] as u8,
2006 arr[16] as u8,
2007 arr[17] as u8,
2008 arr[18] as u8,
2009 arr[19] as u8,
2010 arr[20] as u8,
2011 arr[21] as u8,
2012 arr[22] as u8,
2013 arr[23] as u8,
2014 arr[24] as u8,
2015 arr[25] as u8,
2016 arr[26] as u8,
2017 arr[27] as u8,
2018 arr[28] as u8,
2019 arr[29] as u8,
2020 arr[30] as u8,
2021 arr[31] as u8,
2022 arr[32] as u8,
2023 arr[33] as u8,
2024 arr[34] as u8,
2025 arr[35] as u8,
2026 arr[36] as u8,
2027 arr[37] as u8,
2028 arr[38] as u8,
2029 arr[39] as u8,
2030 arr[40] as u8,
2031 arr[41] as u8,
2032 arr[42] as u8,
2033 arr[43] as u8,
2034 arr[44] as u8,
2035 arr[45] as u8,
2036 arr[46] as u8,
2037 arr[47] as u8,
2038 arr[48] as u8,
2039 arr[49] as u8,
2040 arr[50] as u8,
2041 arr[51] as u8,
2042 arr[52] as u8,
2043 arr[53] as u8,
2044 arr[54] as u8,
2045 arr[55] as u8,
2046 arr[56] as u8,
2047 arr[57] as u8,
2048 arr[58] as u8,
2049 arr[59] as u8,
2050 ]
2051 }
2052 fn write_to_slice(self, target: &mut [u8]) {
2053 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
2054 }
2055}
2056
2057impl FromByteSlice for [i8; 60] {
2058 fn from_le_byte_slice(bytes: &[u8]) -> [i8; 60] {
2059 [
2060 bytes[0] as i8,
2061 bytes[1] as i8,
2062 bytes[2] as i8,
2063 bytes[3] as i8,
2064 bytes[4] as i8,
2065 bytes[5] as i8,
2066 bytes[6] as i8,
2067 bytes[7] as i8,
2068 bytes[8] as i8,
2069 bytes[9] as i8,
2070 bytes[10] as i8,
2071 bytes[11] as i8,
2072 bytes[12] as i8,
2073 bytes[13] as i8,
2074 bytes[14] as i8,
2075 bytes[15] as i8,
2076 bytes[16] as i8,
2077 bytes[17] as i8,
2078 bytes[18] as i8,
2079 bytes[19] as i8,
2080 bytes[20] as i8,
2081 bytes[21] as i8,
2082 bytes[22] as i8,
2083 bytes[23] as i8,
2084 bytes[24] as i8,
2085 bytes[25] as i8,
2086 bytes[26] as i8,
2087 bytes[27] as i8,
2088 bytes[28] as i8,
2089 bytes[29] as i8,
2090 bytes[30] as i8,
2091 bytes[31] as i8,
2092 bytes[32] as i8,
2093 bytes[33] as i8,
2094 bytes[34] as i8,
2095 bytes[35] as i8,
2096 bytes[36] as i8,
2097 bytes[37] as i8,
2098 bytes[38] as i8,
2099 bytes[39] as i8,
2100 bytes[40] as i8,
2101 bytes[41] as i8,
2102 bytes[42] as i8,
2103 bytes[43] as i8,
2104 bytes[44] as i8,
2105 bytes[45] as i8,
2106 bytes[46] as i8,
2107 bytes[47] as i8,
2108 bytes[48] as i8,
2109 bytes[49] as i8,
2110 bytes[50] as i8,
2111 bytes[51] as i8,
2112 bytes[52] as i8,
2113 bytes[53] as i8,
2114 bytes[54] as i8,
2115 bytes[55] as i8,
2116 bytes[56] as i8,
2117 bytes[57] as i8,
2118 bytes[58] as i8,
2119 bytes[59] as i8,
2120 ]
2121 }
2122 fn bytes_expected() -> usize {
2123 60
2124 }
2125}
2126
2127impl ToBytes for [char; 60] {
2128 fn to_le_byte_vec(arr: [char; 60]) -> Vec<u8> {
2129 vec![
2130 arr[0] as u8,
2131 arr[1] as u8,
2132 arr[2] as u8,
2133 arr[3] as u8,
2134 arr[4] as u8,
2135 arr[5] as u8,
2136 arr[6] as u8,
2137 arr[7] as u8,
2138 arr[8] as u8,
2139 arr[9] as u8,
2140 arr[10] as u8,
2141 arr[11] as u8,
2142 arr[12] as u8,
2143 arr[13] as u8,
2144 arr[14] as u8,
2145 arr[15] as u8,
2146 arr[16] as u8,
2147 arr[17] as u8,
2148 arr[18] as u8,
2149 arr[19] as u8,
2150 arr[20] as u8,
2151 arr[21] as u8,
2152 arr[22] as u8,
2153 arr[23] as u8,
2154 arr[24] as u8,
2155 arr[25] as u8,
2156 arr[26] as u8,
2157 arr[27] as u8,
2158 arr[28] as u8,
2159 arr[29] as u8,
2160 arr[30] as u8,
2161 arr[31] as u8,
2162 arr[32] as u8,
2163 arr[33] as u8,
2164 arr[34] as u8,
2165 arr[35] as u8,
2166 arr[36] as u8,
2167 arr[37] as u8,
2168 arr[38] as u8,
2169 arr[39] as u8,
2170 arr[40] as u8,
2171 arr[41] as u8,
2172 arr[42] as u8,
2173 arr[43] as u8,
2174 arr[44] as u8,
2175 arr[45] as u8,
2176 arr[46] as u8,
2177 arr[47] as u8,
2178 arr[48] as u8,
2179 arr[49] as u8,
2180 arr[50] as u8,
2181 arr[51] as u8,
2182 arr[52] as u8,
2183 arr[53] as u8,
2184 arr[54] as u8,
2185 arr[55] as u8,
2186 arr[56] as u8,
2187 arr[57] as u8,
2188 arr[58] as u8,
2189 arr[59] as u8,
2190 ]
2191 }
2192 fn write_to_slice(self, target: &mut [u8]) {
2193 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
2194 }
2195}
2196
2197impl FromByteSlice for [char; 60] {
2198 fn from_le_byte_slice(bytes: &[u8]) -> [char; 60] {
2199 [
2200 bytes[0] as char,
2201 bytes[1] as char,
2202 bytes[2] as char,
2203 bytes[3] as char,
2204 bytes[4] as char,
2205 bytes[5] as char,
2206 bytes[6] as char,
2207 bytes[7] as char,
2208 bytes[8] as char,
2209 bytes[9] as char,
2210 bytes[10] as char,
2211 bytes[11] as char,
2212 bytes[12] as char,
2213 bytes[13] as char,
2214 bytes[14] as char,
2215 bytes[15] as char,
2216 bytes[16] as char,
2217 bytes[17] as char,
2218 bytes[18] as char,
2219 bytes[19] as char,
2220 bytes[20] as char,
2221 bytes[21] as char,
2222 bytes[22] as char,
2223 bytes[23] as char,
2224 bytes[24] as char,
2225 bytes[25] as char,
2226 bytes[26] as char,
2227 bytes[27] as char,
2228 bytes[28] as char,
2229 bytes[29] as char,
2230 bytes[30] as char,
2231 bytes[31] as char,
2232 bytes[32] as char,
2233 bytes[33] as char,
2234 bytes[34] as char,
2235 bytes[35] as char,
2236 bytes[36] as char,
2237 bytes[37] as char,
2238 bytes[38] as char,
2239 bytes[39] as char,
2240 bytes[40] as char,
2241 bytes[41] as char,
2242 bytes[42] as char,
2243 bytes[43] as char,
2244 bytes[44] as char,
2245 bytes[45] as char,
2246 bytes[46] as char,
2247 bytes[47] as char,
2248 bytes[48] as char,
2249 bytes[49] as char,
2250 bytes[50] as char,
2251 bytes[51] as char,
2252 bytes[52] as char,
2253 bytes[53] as char,
2254 bytes[54] as char,
2255 bytes[55] as char,
2256 bytes[56] as char,
2257 bytes[57] as char,
2258 bytes[58] as char,
2259 bytes[59] as char,
2260 ]
2261 }
2262 fn bytes_expected() -> usize {
2263 60
2264 }
2265}
2266
2267impl ToBytes for [char; 61] {
2268 fn to_le_byte_vec(arr: [char; 61]) -> Vec<u8> {
2269 vec![
2270 arr[0] as u8,
2271 arr[1] as u8,
2272 arr[2] as u8,
2273 arr[3] as u8,
2274 arr[4] as u8,
2275 arr[5] as u8,
2276 arr[6] as u8,
2277 arr[7] as u8,
2278 arr[8] as u8,
2279 arr[9] as u8,
2280 arr[10] as u8,
2281 arr[11] as u8,
2282 arr[12] as u8,
2283 arr[13] as u8,
2284 arr[14] as u8,
2285 arr[15] as u8,
2286 arr[16] as u8,
2287 arr[17] as u8,
2288 arr[18] as u8,
2289 arr[19] as u8,
2290 arr[20] as u8,
2291 arr[21] as u8,
2292 arr[22] as u8,
2293 arr[23] as u8,
2294 arr[24] as u8,
2295 arr[25] as u8,
2296 arr[26] as u8,
2297 arr[27] as u8,
2298 arr[28] as u8,
2299 arr[29] as u8,
2300 arr[30] as u8,
2301 arr[31] as u8,
2302 arr[32] as u8,
2303 arr[33] as u8,
2304 arr[34] as u8,
2305 arr[35] as u8,
2306 arr[36] as u8,
2307 arr[37] as u8,
2308 arr[38] as u8,
2309 arr[39] as u8,
2310 arr[40] as u8,
2311 arr[41] as u8,
2312 arr[42] as u8,
2313 arr[43] as u8,
2314 arr[44] as u8,
2315 arr[45] as u8,
2316 arr[46] as u8,
2317 arr[47] as u8,
2318 arr[48] as u8,
2319 arr[49] as u8,
2320 arr[50] as u8,
2321 arr[51] as u8,
2322 arr[52] as u8,
2323 arr[53] as u8,
2324 arr[54] as u8,
2325 arr[55] as u8,
2326 arr[56] as u8,
2327 arr[57] as u8,
2328 arr[58] as u8,
2329 arr[59] as u8,
2330 arr[60] as u8,
2331 ]
2332 }
2333 fn write_to_slice(self, target: &mut [u8]) {
2334 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
2335 }
2336}
2337
2338impl FromByteSlice for [char; 61] {
2339 fn from_le_byte_slice(bytes: &[u8]) -> [char; 61] {
2340 [
2341 bytes[0] as char,
2342 bytes[1] as char,
2343 bytes[2] as char,
2344 bytes[3] as char,
2345 bytes[4] as char,
2346 bytes[5] as char,
2347 bytes[6] as char,
2348 bytes[7] as char,
2349 bytes[8] as char,
2350 bytes[9] as char,
2351 bytes[10] as char,
2352 bytes[11] as char,
2353 bytes[12] as char,
2354 bytes[13] as char,
2355 bytes[14] as char,
2356 bytes[15] as char,
2357 bytes[16] as char,
2358 bytes[17] as char,
2359 bytes[18] as char,
2360 bytes[19] as char,
2361 bytes[20] as char,
2362 bytes[21] as char,
2363 bytes[22] as char,
2364 bytes[23] as char,
2365 bytes[24] as char,
2366 bytes[25] as char,
2367 bytes[26] as char,
2368 bytes[27] as char,
2369 bytes[28] as char,
2370 bytes[29] as char,
2371 bytes[30] as char,
2372 bytes[31] as char,
2373 bytes[32] as char,
2374 bytes[33] as char,
2375 bytes[34] as char,
2376 bytes[35] as char,
2377 bytes[36] as char,
2378 bytes[37] as char,
2379 bytes[38] as char,
2380 bytes[39] as char,
2381 bytes[40] as char,
2382 bytes[41] as char,
2383 bytes[42] as char,
2384 bytes[43] as char,
2385 bytes[44] as char,
2386 bytes[45] as char,
2387 bytes[46] as char,
2388 bytes[47] as char,
2389 bytes[48] as char,
2390 bytes[49] as char,
2391 bytes[50] as char,
2392 bytes[51] as char,
2393 bytes[52] as char,
2394 bytes[53] as char,
2395 bytes[54] as char,
2396 bytes[55] as char,
2397 bytes[56] as char,
2398 bytes[57] as char,
2399 bytes[58] as char,
2400 bytes[59] as char,
2401 bytes[60] as char,
2402 ]
2403 }
2404 fn bytes_expected() -> usize {
2405 61
2406 }
2407}
2408
2409impl ToBytes for [char; 62] {
2410 fn to_le_byte_vec(arr: [char; 62]) -> Vec<u8> {
2411 vec![
2412 arr[0] as u8,
2413 arr[1] as u8,
2414 arr[2] as u8,
2415 arr[3] as u8,
2416 arr[4] as u8,
2417 arr[5] as u8,
2418 arr[6] as u8,
2419 arr[7] as u8,
2420 arr[8] as u8,
2421 arr[9] as u8,
2422 arr[10] as u8,
2423 arr[11] as u8,
2424 arr[12] as u8,
2425 arr[13] as u8,
2426 arr[14] as u8,
2427 arr[15] as u8,
2428 arr[16] as u8,
2429 arr[17] as u8,
2430 arr[18] as u8,
2431 arr[19] as u8,
2432 arr[20] as u8,
2433 arr[21] as u8,
2434 arr[22] as u8,
2435 arr[23] as u8,
2436 arr[24] as u8,
2437 arr[25] as u8,
2438 arr[26] as u8,
2439 arr[27] as u8,
2440 arr[28] as u8,
2441 arr[29] as u8,
2442 arr[30] as u8,
2443 arr[31] as u8,
2444 arr[32] as u8,
2445 arr[33] as u8,
2446 arr[34] as u8,
2447 arr[35] as u8,
2448 arr[36] as u8,
2449 arr[37] as u8,
2450 arr[38] as u8,
2451 arr[39] as u8,
2452 arr[40] as u8,
2453 arr[41] as u8,
2454 arr[42] as u8,
2455 arr[43] as u8,
2456 arr[44] as u8,
2457 arr[45] as u8,
2458 arr[46] as u8,
2459 arr[47] as u8,
2460 arr[48] as u8,
2461 arr[49] as u8,
2462 arr[50] as u8,
2463 arr[51] as u8,
2464 arr[52] as u8,
2465 arr[53] as u8,
2466 arr[54] as u8,
2467 arr[55] as u8,
2468 arr[56] as u8,
2469 arr[57] as u8,
2470 arr[58] as u8,
2471 arr[59] as u8,
2472 arr[60] as u8,
2473 arr[61] as u8,
2474 ]
2475 }
2476 fn write_to_slice(self, target: &mut [u8]) {
2477 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
2478 }
2479}
2480
2481impl FromByteSlice for [char; 62] {
2482 fn from_le_byte_slice(bytes: &[u8]) -> [char; 62] {
2483 [
2484 bytes[0] as char,
2485 bytes[1] as char,
2486 bytes[2] as char,
2487 bytes[3] as char,
2488 bytes[4] as char,
2489 bytes[5] as char,
2490 bytes[6] as char,
2491 bytes[7] as char,
2492 bytes[8] as char,
2493 bytes[9] as char,
2494 bytes[10] as char,
2495 bytes[11] as char,
2496 bytes[12] as char,
2497 bytes[13] as char,
2498 bytes[14] as char,
2499 bytes[15] as char,
2500 bytes[16] as char,
2501 bytes[17] as char,
2502 bytes[18] as char,
2503 bytes[19] as char,
2504 bytes[20] as char,
2505 bytes[21] as char,
2506 bytes[22] as char,
2507 bytes[23] as char,
2508 bytes[24] as char,
2509 bytes[25] as char,
2510 bytes[26] as char,
2511 bytes[27] as char,
2512 bytes[28] as char,
2513 bytes[29] as char,
2514 bytes[30] as char,
2515 bytes[31] as char,
2516 bytes[32] as char,
2517 bytes[33] as char,
2518 bytes[34] as char,
2519 bytes[35] as char,
2520 bytes[36] as char,
2521 bytes[37] as char,
2522 bytes[38] as char,
2523 bytes[39] as char,
2524 bytes[40] as char,
2525 bytes[41] as char,
2526 bytes[42] as char,
2527 bytes[43] as char,
2528 bytes[44] as char,
2529 bytes[45] as char,
2530 bytes[46] as char,
2531 bytes[47] as char,
2532 bytes[48] as char,
2533 bytes[49] as char,
2534 bytes[50] as char,
2535 bytes[51] as char,
2536 bytes[52] as char,
2537 bytes[53] as char,
2538 bytes[54] as char,
2539 bytes[55] as char,
2540 bytes[56] as char,
2541 bytes[57] as char,
2542 bytes[58] as char,
2543 bytes[59] as char,
2544 bytes[60] as char,
2545 bytes[61] as char,
2546 ]
2547 }
2548 fn bytes_expected() -> usize {
2549 62
2550 }
2551}
2552
2553impl ToBytes for [char; 63] {
2554 fn to_le_byte_vec(arr: [char; 63]) -> Vec<u8> {
2555 vec![
2556 arr[0] as u8,
2557 arr[1] as u8,
2558 arr[2] as u8,
2559 arr[3] as u8,
2560 arr[4] as u8,
2561 arr[5] as u8,
2562 arr[6] as u8,
2563 arr[7] as u8,
2564 arr[8] as u8,
2565 arr[9] as u8,
2566 arr[10] as u8,
2567 arr[11] as u8,
2568 arr[12] as u8,
2569 arr[13] as u8,
2570 arr[14] as u8,
2571 arr[15] as u8,
2572 arr[16] as u8,
2573 arr[17] as u8,
2574 arr[18] as u8,
2575 arr[19] as u8,
2576 arr[20] as u8,
2577 arr[21] as u8,
2578 arr[22] as u8,
2579 arr[23] as u8,
2580 arr[24] as u8,
2581 arr[25] as u8,
2582 arr[26] as u8,
2583 arr[27] as u8,
2584 arr[28] as u8,
2585 arr[29] as u8,
2586 arr[30] as u8,
2587 arr[31] as u8,
2588 arr[32] as u8,
2589 arr[33] as u8,
2590 arr[34] as u8,
2591 arr[35] as u8,
2592 arr[36] as u8,
2593 arr[37] as u8,
2594 arr[38] as u8,
2595 arr[39] as u8,
2596 arr[40] as u8,
2597 arr[41] as u8,
2598 arr[42] as u8,
2599 arr[43] as u8,
2600 arr[44] as u8,
2601 arr[45] as u8,
2602 arr[46] as u8,
2603 arr[47] as u8,
2604 arr[48] as u8,
2605 arr[49] as u8,
2606 arr[50] as u8,
2607 arr[51] as u8,
2608 arr[52] as u8,
2609 arr[53] as u8,
2610 arr[54] as u8,
2611 arr[55] as u8,
2612 arr[56] as u8,
2613 arr[57] as u8,
2614 arr[58] as u8,
2615 arr[59] as u8,
2616 arr[60] as u8,
2617 arr[61] as u8,
2618 arr[62] as u8,
2619 ]
2620 }
2621 fn write_to_slice(self, target: &mut [u8]) {
2622 self.into_iter().enumerate().for_each(|(i, v)| target[i] = *v as u8);
2623 }
2624}
2625
2626impl FromByteSlice for [char; 63] {
2627 fn from_le_byte_slice(bytes: &[u8]) -> [char; 63] {
2628 [
2629 bytes[0] as char,
2630 bytes[1] as char,
2631 bytes[2] as char,
2632 bytes[3] as char,
2633 bytes[4] as char,
2634 bytes[5] as char,
2635 bytes[6] as char,
2636 bytes[7] as char,
2637 bytes[8] as char,
2638 bytes[9] as char,
2639 bytes[10] as char,
2640 bytes[11] as char,
2641 bytes[12] as char,
2642 bytes[13] as char,
2643 bytes[14] as char,
2644 bytes[15] as char,
2645 bytes[16] as char,
2646 bytes[17] as char,
2647 bytes[18] as char,
2648 bytes[19] as char,
2649 bytes[20] as char,
2650 bytes[21] as char,
2651 bytes[22] as char,
2652 bytes[23] as char,
2653 bytes[24] as char,
2654 bytes[25] as char,
2655 bytes[26] as char,
2656 bytes[27] as char,
2657 bytes[28] as char,
2658 bytes[29] as char,
2659 bytes[30] as char,
2660 bytes[31] as char,
2661 bytes[32] as char,
2662 bytes[33] as char,
2663 bytes[34] as char,
2664 bytes[35] as char,
2665 bytes[36] as char,
2666 bytes[37] as char,
2667 bytes[38] as char,
2668 bytes[39] as char,
2669 bytes[40] as char,
2670 bytes[41] as char,
2671 bytes[42] as char,
2672 bytes[43] as char,
2673 bytes[44] as char,
2674 bytes[45] as char,
2675 bytes[46] as char,
2676 bytes[47] as char,
2677 bytes[48] as char,
2678 bytes[49] as char,
2679 bytes[50] as char,
2680 bytes[51] as char,
2681 bytes[52] as char,
2682 bytes[53] as char,
2683 bytes[54] as char,
2684 bytes[55] as char,
2685 bytes[56] as char,
2686 bytes[57] as char,
2687 bytes[58] as char,
2688 bytes[59] as char,
2689 bytes[60] as char,
2690 bytes[61] as char,
2691 bytes[62] as char,
2692 ]
2693 }
2694 fn bytes_expected() -> usize {
2695 63
2696 }
2697}
2698
2699impl ToBytes for [u16; 2] {
2700 fn to_le_byte_vec(arr: [u16; 2]) -> Vec<u8> {
2701 let mut buf = vec![0, 4];
2702 LittleEndian::write_u16_into(&arr, &mut buf);
2703 buf
2704 }
2705 fn write_to_slice(self, target: &mut [u8]) {
2706 LittleEndian::write_u16_into(&self, target);
2707 }
2708}
2709
2710impl FromByteSlice for [u16; 2] {
2711 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 2] {
2712 let mut buf = [0u16; 2];
2713 LittleEndian::read_u16_into(&bytes, &mut buf);
2714 buf
2715 }
2716 fn bytes_expected() -> usize {
2717 4
2718 }
2719}
2720
2721impl ToBytes for [u16; 4] {
2722 fn to_le_byte_vec(arr: [u16; 4]) -> Vec<u8> {
2723 let mut buf = vec![0, 8];
2724 LittleEndian::write_u16_into(&arr, &mut buf);
2725 buf
2726 }
2727 fn write_to_slice(self, target: &mut [u8]) {
2728 LittleEndian::write_u16_into(&self, target);
2729 }
2730}
2731
2732impl FromByteSlice for [u16; 4] {
2733 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 4] {
2734 let mut buf = [0u16; 4];
2735 LittleEndian::read_u16_into(&bytes, &mut buf);
2736 buf
2737 }
2738 fn bytes_expected() -> usize {
2739 8
2740 }
2741}
2742
2743impl ToBytes for [u16; 7] {
2744 fn to_le_byte_vec(arr: [u16; 7]) -> Vec<u8> {
2745 let mut buf = vec![0, 14];
2746 LittleEndian::write_u16_into(&arr, &mut buf);
2747 buf
2748 }
2749 fn write_to_slice(self, target: &mut [u8]) {
2750 LittleEndian::write_u16_into(&self, target);
2751 }
2752}
2753
2754impl FromByteSlice for [u16; 7] {
2755 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 7] {
2756 let mut buf = [0u16; 7];
2757 LittleEndian::read_u16_into(&bytes, &mut buf);
2758 buf
2759 }
2760 fn bytes_expected() -> usize {
2761 14
2762 }
2763}
2764
2765impl ToBytes for [u16; 8] {
2766 fn to_le_byte_vec(arr: [u16; 8]) -> Vec<u8> {
2767 let mut buf = vec![0, 16];
2768 LittleEndian::write_u16_into(&arr, &mut buf);
2769 buf
2770 }
2771 fn write_to_slice(self, target: &mut [u8]) {
2772 LittleEndian::write_u16_into(&self, target);
2773 }
2774}
2775
2776impl FromByteSlice for [u16; 8] {
2777 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 8] {
2778 let mut buf = [0u16; 8];
2779 LittleEndian::read_u16_into(&bytes, &mut buf);
2780 buf
2781 }
2782 fn bytes_expected() -> usize {
2783 16
2784 }
2785}
2786
2787impl ToBytes for [u16; 10] {
2788 fn to_le_byte_vec(arr: [u16; 10]) -> Vec<u8> {
2789 let mut buf = vec![0, 20];
2790 LittleEndian::write_u16_into(&arr, &mut buf);
2791 buf
2792 }
2793 fn write_to_slice(self, target: &mut [u8]) {
2794 LittleEndian::write_u16_into(&self, target);
2795 }
2796}
2797
2798impl FromByteSlice for [u16; 10] {
2799 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 10] {
2800 let mut buf = [0u16; 10];
2801 LittleEndian::read_u16_into(&bytes, &mut buf);
2802 buf
2803 }
2804 fn bytes_expected() -> usize {
2805 20
2806 }
2807}
2808
2809impl ToBytes for [u16; 20] {
2810 fn to_le_byte_vec(arr: [u16; 20]) -> Vec<u8> {
2811 let mut buf = vec![0, 40];
2812 LittleEndian::write_u16_into(&arr, &mut buf);
2813 buf
2814 }
2815 fn write_to_slice(self, target: &mut [u8]) {
2816 LittleEndian::write_u16_into(&self, target);
2817 }
2818}
2819
2820impl FromByteSlice for [u16; 20] {
2821 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 20] {
2822 let mut buf = [0u16; 20];
2823 LittleEndian::read_u16_into(&bytes, &mut buf);
2824 buf
2825 }
2826 fn bytes_expected() -> usize {
2827 40
2828 }
2829}
2830
2831impl ToBytes for [u16; 27] {
2832 fn to_le_byte_vec(arr: [u16; 27]) -> Vec<u8> {
2833 let mut buf = vec![0, 54];
2834 LittleEndian::write_u16_into(&arr, &mut buf);
2835 buf
2836 }
2837 fn write_to_slice(self, target: &mut [u8]) {
2838 LittleEndian::write_u16_into(&self, target);
2839 }
2840}
2841
2842impl FromByteSlice for [u16; 27] {
2843 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 27] {
2844 let mut buf = [0u16; 27];
2845 LittleEndian::read_u16_into(&bytes, &mut buf);
2846 buf
2847 }
2848 fn bytes_expected() -> usize {
2849 54
2850 }
2851}
2852
2853impl ToBytes for [u16; 29] {
2854 fn to_le_byte_vec(arr: [u16; 29]) -> Vec<u8> {
2855 let mut buf = vec![0, 58];
2856 LittleEndian::write_u16_into(&arr, &mut buf);
2857 buf
2858 }
2859 fn write_to_slice(self, target: &mut [u8]) {
2860 LittleEndian::write_u16_into(&self, target);
2861 }
2862}
2863
2864impl FromByteSlice for [u16; 29] {
2865 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 29] {
2866 let mut buf = [0u16; 29];
2867 LittleEndian::read_u16_into(&bytes, &mut buf);
2868 buf
2869 }
2870 fn bytes_expected() -> usize {
2871 58
2872 }
2873}
2874
2875impl ToBytes for [u16; 30] {
2876 fn to_le_byte_vec(arr: [u16; 30]) -> Vec<u8> {
2877 let mut buf = vec![0, 60];
2878 LittleEndian::write_u16_into(&arr, &mut buf);
2879 buf
2880 }
2881 fn write_to_slice(self, target: &mut [u8]) {
2882 LittleEndian::write_u16_into(&self, target);
2883 }
2884}
2885
2886impl FromByteSlice for [u16; 30] {
2887 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 30] {
2888 let mut buf = [0u16; 30];
2889 LittleEndian::read_u16_into(&bytes, &mut buf);
2890 buf
2891 }
2892 fn bytes_expected() -> usize {
2893 60
2894 }
2895}
2896
2897impl ToBytes for [u16; 31] {
2898 fn to_le_byte_vec(arr: [u16; 31]) -> Vec<u8> {
2899 let mut buf = vec![0, 62];
2900 LittleEndian::write_u16_into(&arr, &mut buf);
2901 buf
2902 }
2903 fn write_to_slice(self, target: &mut [u8]) {
2904 LittleEndian::write_u16_into(&self, target);
2905 }
2906}
2907
2908impl FromByteSlice for [u16; 31] {
2909 fn from_le_byte_slice(bytes: &[u8]) -> [u16; 31] {
2910 let mut buf = [0u16; 31];
2911 LittleEndian::read_u16_into(&bytes, &mut buf);
2912 buf
2913 }
2914 fn bytes_expected() -> usize {
2915 62
2916 }
2917}
2918
2919impl ToBytes for [i16; 3] {
2920 fn to_le_byte_vec(arr: [i16; 3]) -> Vec<u8> {
2921 let mut buf = vec![0, 6];
2922 LittleEndian::write_i16_into(&arr, &mut buf);
2923 buf
2924 }
2925 fn write_to_slice(self, target: &mut [u8]) {
2926 LittleEndian::write_i16_into(&self, target);
2927 }
2928}
2929
2930impl FromByteSlice for [i16; 3] {
2931 fn from_le_byte_slice(bytes: &[u8]) -> [i16; 3] {
2932 let mut buf = [0i16; 3];
2933 LittleEndian::read_i16_into(&bytes, &mut buf);
2934 buf
2935 }
2936 fn bytes_expected() -> usize {
2937 6
2938 }
2939}
2940
2941impl ToBytes for [i16; 4] {
2942 fn to_le_byte_vec(arr: [i16; 4]) -> Vec<u8> {
2943 let mut buf = vec![0, 8];
2944 LittleEndian::write_i16_into(&arr, &mut buf);
2945 buf
2946 }
2947 fn write_to_slice(self, target: &mut [u8]) {
2948 LittleEndian::write_i16_into(&self, target);
2949 }
2950}
2951
2952impl FromByteSlice for [i16; 4] {
2953 fn from_le_byte_slice(bytes: &[u8]) -> [i16; 4] {
2954 let mut buf = [0i16; 4];
2955 LittleEndian::read_i16_into(&bytes, &mut buf);
2956 buf
2957 }
2958 fn bytes_expected() -> usize {
2959 8
2960 }
2961}
2962
2963impl ToBytes for [i16; 7] {
2964 fn to_le_byte_vec(arr: [i16; 7]) -> Vec<u8> {
2965 let mut buf = vec![0, 14];
2966 LittleEndian::write_i16_into(&arr, &mut buf);
2967 buf
2968 }
2969 fn write_to_slice(self, target: &mut [u8]) {
2970 LittleEndian::write_i16_into(&self, target);
2971 }
2972}
2973
2974impl FromByteSlice for [i16; 7] {
2975 fn from_le_byte_slice(bytes: &[u8]) -> [i16; 7] {
2976 let mut buf = [0i16; 7];
2977 LittleEndian::read_i16_into(&bytes, &mut buf);
2978 buf
2979 }
2980 fn bytes_expected() -> usize {
2981 14
2982 }
2983}
2984
2985impl ToBytes for [i16; 10] {
2986 fn to_le_byte_vec(arr: [i16; 10]) -> Vec<u8> {
2987 let mut buf = vec![0, 20];
2988 LittleEndian::write_i16_into(&arr, &mut buf);
2989 buf
2990 }
2991 fn write_to_slice(self, target: &mut [u8]) {
2992 LittleEndian::write_i16_into(&self, target);
2993 }
2994}
2995
2996impl FromByteSlice for [i16; 10] {
2997 fn from_le_byte_slice(bytes: &[u8]) -> [i16; 10] {
2998 let mut buf = [0i16; 10];
2999 LittleEndian::read_i16_into(&bytes, &mut buf);
3000 buf
3001 }
3002 fn bytes_expected() -> usize {
3003 20
3004 }
3005}
3006
3007impl ToBytes for [i16; 14] {
3008 fn to_le_byte_vec(arr: [i16; 14]) -> Vec<u8> {
3009 let mut buf = vec![0, 28];
3010 LittleEndian::write_i16_into(&arr, &mut buf);
3011 buf
3012 }
3013 fn write_to_slice(self, target: &mut [u8]) {
3014 LittleEndian::write_i16_into(&self, target);
3015 }
3016}
3017
3018impl FromByteSlice for [i16; 14] {
3019 fn from_le_byte_slice(bytes: &[u8]) -> [i16; 14] {
3020 let mut buf = [0i16; 14];
3021 LittleEndian::read_i16_into(&bytes, &mut buf);
3022 buf
3023 }
3024 fn bytes_expected() -> usize {
3025 28
3026 }
3027}
3028
3029impl ToBytes for [i16; 30] {
3030 fn to_le_byte_vec(arr: [i16; 30]) -> Vec<u8> {
3031 let mut buf = vec![0, 60];
3032 LittleEndian::write_i16_into(&arr, &mut buf);
3033 buf
3034 }
3035 fn write_to_slice(self, target: &mut [u8]) {
3036 LittleEndian::write_i16_into(&self, target);
3037 }
3038}
3039
3040impl FromByteSlice for [i16; 30] {
3041 fn from_le_byte_slice(bytes: &[u8]) -> [i16; 30] {
3042 let mut buf = [0i16; 30];
3043 LittleEndian::read_i16_into(&bytes, &mut buf);
3044 buf
3045 }
3046 fn bytes_expected() -> usize {
3047 60
3048 }
3049}
3050
3051impl ToBytes for [u32; 2] {
3052 fn to_le_byte_vec(arr: [u32; 2]) -> Vec<u8> {
3053 let mut buf = vec![0, 8];
3054 LittleEndian::write_u32_into(&arr, &mut buf);
3055 buf
3056 }
3057 fn write_to_slice(self, target: &mut [u8]) {
3058 LittleEndian::write_u32_into(&self, target);
3059 }
3060}
3061
3062impl FromByteSlice for [u32; 2] {
3063 fn from_le_byte_slice(bytes: &[u8]) -> [u32; 2] {
3064 let mut buf = [0u32; 2];
3065 LittleEndian::read_u32_into(&bytes, &mut buf);
3066 buf
3067 }
3068 fn bytes_expected() -> usize {
3069 8
3070 }
3071}
3072
3073impl ToBytes for [u32; 4] {
3074 fn to_le_byte_vec(arr: [u32; 4]) -> Vec<u8> {
3075 let mut buf = vec![0, 16];
3076 LittleEndian::write_u32_into(&arr, &mut buf);
3077 buf
3078 }
3079 fn write_to_slice(self, target: &mut [u8]) {
3080 LittleEndian::write_u32_into(&self, target);
3081 }
3082}
3083
3084impl FromByteSlice for [u32; 4] {
3085 fn from_le_byte_slice(bytes: &[u8]) -> [u32; 4] {
3086 let mut buf = [0u32; 4];
3087 LittleEndian::read_u32_into(&bytes, &mut buf);
3088 buf
3089 }
3090 fn bytes_expected() -> usize {
3091 16
3092 }
3093}
3094
3095impl ToBytes for [u32; 6] {
3096 fn to_le_byte_vec(arr: [u32; 6]) -> Vec<u8> {
3097 let mut buf = vec![0, 24];
3098 LittleEndian::write_u32_into(&arr, &mut buf);
3099 buf
3100 }
3101 fn write_to_slice(self, target: &mut [u8]) {
3102 LittleEndian::write_u32_into(&self, target);
3103 }
3104}
3105
3106impl FromByteSlice for [u32; 6] {
3107 fn from_le_byte_slice(bytes: &[u8]) -> [u32; 6] {
3108 let mut buf = [0u32; 6];
3109 LittleEndian::read_u32_into(&bytes, &mut buf);
3110 buf
3111 }
3112 fn bytes_expected() -> usize {
3113 24
3114 }
3115}
3116
3117impl ToBytes for [u32; 14] {
3118 fn to_le_byte_vec(arr: [u32; 14]) -> Vec<u8> {
3119 let mut buf = vec![0, 56];
3120 LittleEndian::write_u32_into(&arr, &mut buf);
3121 buf
3122 }
3123 fn write_to_slice(self, target: &mut [u8]) {
3124 LittleEndian::write_u32_into(&self, target);
3125 }
3126}
3127
3128impl FromByteSlice for [u32; 14] {
3129 fn from_le_byte_slice(bytes: &[u8]) -> [u32; 14] {
3130 let mut buf = [0u32; 14];
3131 LittleEndian::read_u32_into(&bytes, &mut buf);
3132 buf
3133 }
3134 fn bytes_expected() -> usize {
3135 56
3136 }
3137}
3138
3139impl ToBytes for [u32; 15] {
3140 fn to_le_byte_vec(arr: [u32; 15]) -> Vec<u8> {
3141 let mut buf = vec![0, 60];
3142 LittleEndian::write_u32_into(&arr, &mut buf);
3143 buf
3144 }
3145 fn write_to_slice(self, target: &mut [u8]) {
3146 LittleEndian::write_u32_into(&self, target);
3147 }
3148}
3149
3150impl FromByteSlice for [u32; 15] {
3151 fn from_le_byte_slice(bytes: &[u8]) -> [u32; 15] {
3152 let mut buf = [0u32; 15];
3153 LittleEndian::read_u32_into(&bytes, &mut buf);
3154 buf
3155 }
3156 fn bytes_expected() -> usize {
3157 60
3158 }
3159}
3160
3161impl ToBytes for [i32; 2] {
3162 fn to_le_byte_vec(arr: [i32; 2]) -> Vec<u8> {
3163 let mut buf = vec![0, 8];
3164 LittleEndian::write_i32_into(&arr, &mut buf);
3165 buf
3166 }
3167 fn write_to_slice(self, target: &mut [u8]) {
3168 LittleEndian::write_i32_into(&self, target);
3169 }
3170}
3171
3172impl FromByteSlice for [i32; 2] {
3173 fn from_le_byte_slice(bytes: &[u8]) -> [i32; 2] {
3174 let mut buf = [0i32; 2];
3175 LittleEndian::read_i32_into(&bytes, &mut buf);
3176 buf
3177 }
3178 fn bytes_expected() -> usize {
3179 8
3180 }
3181}
3182
3183impl ToBytes for [i32; 4] {
3184 fn to_le_byte_vec(arr: [i32; 4]) -> Vec<u8> {
3185 let mut buf = vec![0, 16];
3186 LittleEndian::write_i32_into(&arr, &mut buf);
3187 buf
3188 }
3189 fn write_to_slice(self, target: &mut [u8]) {
3190 LittleEndian::write_i32_into(&self, target);
3191 }
3192}
3193
3194impl FromByteSlice for [i32; 4] {
3195 fn from_le_byte_slice(bytes: &[u8]) -> [i32; 4] {
3196 let mut buf = [0i32; 4];
3197 LittleEndian::read_i32_into(&bytes, &mut buf);
3198 buf
3199 }
3200 fn bytes_expected() -> usize {
3201 16
3202 }
3203}
3204
3205impl ToBytes for [i32; 6] {
3206 fn to_le_byte_vec(arr: [i32; 6]) -> Vec<u8> {
3207 let mut buf = vec![0, 24];
3208 LittleEndian::write_i32_into(&arr, &mut buf);
3209 buf
3210 }
3211 fn write_to_slice(self, target: &mut [u8]) {
3212 LittleEndian::write_i32_into(&self, target);
3213 }
3214}
3215
3216impl FromByteSlice for [i32; 6] {
3217 fn from_le_byte_slice(bytes: &[u8]) -> [i32; 6] {
3218 let mut buf = [0i32; 6];
3219 LittleEndian::read_i32_into(&bytes, &mut buf);
3220 buf
3221 }
3222 fn bytes_expected() -> usize {
3223 24
3224 }
3225}
3226
3227impl ToBytes for [u64; 4] {
3228 fn to_le_byte_vec(arr: [u64; 4]) -> Vec<u8> {
3229 let mut buf = vec![0, 32];
3230 LittleEndian::write_u64_into(&arr, &mut buf);
3231 buf
3232 }
3233 fn write_to_slice(self, target: &mut [u8]) {
3234 LittleEndian::write_u64_into(&self, target);
3235 }
3236}
3237
3238impl FromByteSlice for [u64; 4] {
3239 fn from_le_byte_slice(bytes: &[u8]) -> [u64; 4] {
3240 let mut buf = [0u64; 4];
3241 LittleEndian::read_u64_into(&bytes, &mut buf);
3242 buf
3243 }
3244 fn bytes_expected() -> usize {
3245 32
3246 }
3247}
3248
3249impl ToBytes for [u64; 7] {
3250 fn to_le_byte_vec(arr: [u64; 7]) -> Vec<u8> {
3251 let mut buf = vec![0, 56];
3252 LittleEndian::write_u64_into(&arr, &mut buf);
3253 buf
3254 }
3255 fn write_to_slice(self, target: &mut [u8]) {
3256 LittleEndian::write_u64_into(&self, target);
3257 }
3258}
3259
3260impl FromByteSlice for [u64; 7] {
3261 fn from_le_byte_slice(bytes: &[u8]) -> [u64; 7] {
3262 let mut buf = [0u64; 7];
3263 LittleEndian::read_u64_into(&bytes, &mut buf);
3264 buf
3265 }
3266 fn bytes_expected() -> usize {
3267 56
3268 }
3269}
3270
3271impl ToBytes for [i64; 4] {
3272 fn to_le_byte_vec(arr: [i64; 4]) -> Vec<u8> {
3273 let mut buf = vec![0, 32];
3274 LittleEndian::write_i64_into(&arr, &mut buf);
3275 buf
3276 }
3277 fn write_to_slice(self, target: &mut [u8]) {
3278 LittleEndian::write_i64_into(&self, target);
3279 }
3280}
3281
3282impl FromByteSlice for [i64; 4] {
3283 fn from_le_byte_slice(bytes: &[u8]) -> [i64; 4] {
3284 let mut buf = [0i64; 4];
3285 LittleEndian::read_i64_into(&bytes, &mut buf);
3286 buf
3287 }
3288 fn bytes_expected() -> usize {
3289 32
3290 }
3291}
3292
3293impl ToBytes for [f32; 3] {
3294 fn to_le_byte_vec(arr: [f32; 3]) -> Vec<u8> {
3295 let mut buf = vec![0, 12];
3296 LittleEndian::write_f32_into(&arr, &mut buf);
3297 buf
3298 }
3299 fn write_to_slice(self, target: &mut [u8]) {
3300 LittleEndian::write_f32_into(&self, target);
3301 }
3302}
3303
3304impl FromByteSlice for [f32; 3] {
3305 fn from_le_byte_slice(bytes: &[u8]) -> [f32; 3] {
3306 let mut buf = [0f32; 3];
3307 LittleEndian::read_f32_into_unchecked(&bytes, &mut buf);
3308 buf
3309 }
3310 fn bytes_expected() -> usize {
3311 12
3312 }
3313}
3314
3315impl ToBytes for [f32; 15] {
3316 fn to_le_byte_vec(arr: [f32; 15]) -> Vec<u8> {
3317 let mut buf = vec![0, 60];
3318 LittleEndian::write_f32_into(&arr, &mut buf);
3319 buf
3320 }
3321 fn write_to_slice(self, target: &mut [u8]) {
3322 LittleEndian::write_f32_into(&self, target);
3323 }
3324}
3325
3326impl FromByteSlice for [f32; 15] {
3327 fn from_le_byte_slice(bytes: &[u8]) -> [f32; 15] {
3328 let mut buf = [0f32; 15];
3329 LittleEndian::read_f32_into_unchecked(&bytes, &mut buf);
3330 buf
3331 }
3332 fn bytes_expected() -> usize {
3333 60
3334 }
3335}