• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use super::prelude::*;
2 use crate::protocol::common::hex::decode_bin_buf;
3 
4 #[derive(Debug)]
5 pub struct X<'a> {
6     pub addr: &'a [u8],
7     pub val: &'a [u8],
8 }
9 
10 impl<'a> ParseCommand<'a> for X<'a> {
11     #[inline(always)]
from_packet(buf: PacketBuf<'a>) -> Option<Self>12     fn from_packet(buf: PacketBuf<'a>) -> Option<Self> {
13         let body = buf.into_body();
14 
15         let mut body = body.splitn_mut(3, |&b| b == b',' || b == b':');
16         let addr = decode_hex_buf(body.next()?).ok()?;
17         // See the comment in `_m_upcase.rs` for why the `len` field is handled
18         // this way. All the same rationale applies here (given that the X
19         // packet is just a new-and-improved version of the M packet).
20         let _len: usize = decode_hex(body.next()?).ok()?;
21         let val = decode_bin_buf(body.next()?)?;
22 
23         Some(X { addr, val })
24     }
25 }
26