(cookie: &BigInt)
| 2569 | const BYTE_LEN: usize = Self::BYTES_TO_SKIP_OFF + 4; |
| 2570 | |
| 2571 | fn parse(cookie: &BigInt) -> Option<Self> { |
| 2572 | let (_, mut buf) = cookie.to_bytes_le(); |
| 2573 | if buf.len() > Self::BYTE_LEN { |
| 2574 | return None; |
| 2575 | } |
| 2576 | buf.resize(Self::BYTE_LEN, 0); |
| 2577 | let buf: &[u8; Self::BYTE_LEN] = buf.as_array()?; |
| 2578 | macro_rules! get_field { |
| 2579 | ($t:ty, $off:ident) => { |
| 2580 | <$t>::from_ne_bytes(*buf[Self::$off..].first_chunk().unwrap()) |
| 2581 | }; |
| 2582 | } |
| 2583 | Some(Self { |
| 2584 | start_pos: get_field!(Offset, START_POS_OFF), |
| 2585 | dec_flags: get_field!(i32, DEC_FLAGS_OFF), |
| 2586 | bytes_to_feed: get_field!(i32, BYTES_TO_FEED_OFF), |
| 2587 | chars_to_skip: get_field!(i32, CHARS_TO_SKIP_OFF), |
| 2588 | need_eof: get_field!(u8, NEED_EOF_OFF) != 0, |
| 2589 | bytes_to_skip: get_field!(i32, BYTES_TO_SKIP_OFF), |
| 2590 | }) |
| 2591 | } |
| 2592 | |
| 2593 | fn build(&self) -> BigInt { |
| 2594 | let mut buf = [0; Self::BYTE_LEN]; |
no test coverage detected