frame_picker/
iap2_frame_meta.rs1use crate::frame_meta::FrameMeta;
2
3#[derive(Debug, Default)]
4pub struct Iap2FrameMeta { }
5
6impl FrameMeta for Iap2FrameMeta {
7 fn frame_header_len() -> usize {
8 6
9 }
10
11 fn frame_match(data : &[u8]) -> bool {
12 if data.len() < Self::frame_header_len() {
13 return false;
14 }
15 match (data[0], data[1], data[4]) {
16 (0xff, 0x5a, _) => true,
17 (0xff, 0x55, 0xee) => true,
18 _ => false,
19 }
20 }
21
22 fn frame_totol_len(data: &[u8]) -> usize {
23 if Self::frame_match(data) {
24 match (data[0], data[1]) {
25 (0xff, 0x55) => 6,
26 (0xff, 0x5a) => {
27 ((((data[2] as u16) << 8) | (data[3] as u16)) as usize).into()
28 },
29 _ => 0,
30 }
31 } else {
32 0
33 }
34 }
35}