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