1 use super::prelude::*; 2 use crate::protocol::common::hex::decode_bin_buf; 3 4 #[derive(Debug)] 5 pub struct vFilePwrite<'a> { 6 pub fd: u32, 7 pub offset: &'a [u8], 8 pub data: &'a [u8], 9 } 10 11 impl<'a> ParseCommand<'a> for vFilePwrite<'a> { 12 #[inline(always)] from_packet(buf: PacketBuf<'a>) -> Option<Self>13 fn from_packet(buf: PacketBuf<'a>) -> Option<Self> { 14 let body = buf.into_body(); 15 if body.is_empty() { 16 return None; 17 } 18 19 match body { 20 [b':', body @ ..] => { 21 let mut body = body.splitn_mut(3, |b| *b == b','); 22 let fd = decode_hex(body.next()?).ok()?; 23 let offset = decode_hex_buf(body.next()?).ok()?; 24 let data = decode_bin_buf(body.next()?)?; 25 Some(vFilePwrite { fd, offset, data }) 26 } 27 _ => None, 28 } 29 } 30 } 31