1 use super::prelude::*; 2 3 #[derive(Debug)] 4 pub struct vFilePread<'a> { 5 pub fd: u32, 6 pub count: usize, 7 pub offset: u64, 8 9 pub buf: &'a mut [u8], 10 } 11 12 impl<'a> ParseCommand<'a> for vFilePread<'a> { 13 #[inline(always)] from_packet(buf: PacketBuf<'a>) -> Option<Self>14 fn from_packet(buf: PacketBuf<'a>) -> Option<Self> { 15 let (buf, body_range) = buf.into_raw_buf(); 16 let body = buf.get_mut(body_range.start..body_range.end)?; 17 18 if body.is_empty() { 19 return None; 20 } 21 22 match body { 23 [b':', body @ ..] => { 24 let mut body = body.splitn_mut(3, |b| *b == b','); 25 let fd = decode_hex(body.next()?).ok()?; 26 let count = decode_hex(body.next()?).ok()?; 27 let offset = decode_hex(body.next()?).ok()?; 28 29 Some(vFilePread { 30 fd, 31 count, 32 offset, 33 buf, 34 }) 35 } 36 _ => None, 37 } 38 } 39 } 40