1 use super::prelude::*; 2 3 use crate::protocol::common::hex::decode_bin_buf; 4 5 #[derive(Debug)] 6 pub struct X<'a> { 7 pub addr: &'a [u8], 8 pub len: usize, 9 pub val: &'a [u8], 10 } 11 12 impl<'a> ParseCommand<'a> for X<'a> { 13 #[inline(always)] from_packet(buf: PacketBuf<'a>) -> Option<Self>14 fn from_packet(buf: PacketBuf<'a>) -> Option<Self> { 15 let body = buf.into_body(); 16 17 let mut body = body.splitn_mut(3, |&b| b == b',' || b == b':'); 18 let addr = decode_hex_buf(body.next()?).ok()?; 19 let len = decode_hex(body.next()?).ok()?; 20 let val = decode_bin_buf(body.next()?)?; 21 22 Some(X { addr, len, val }) 23 } 24 } 25