• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use super::prelude::*;
2 
3 #[derive(Debug)]
4 pub struct vFileReadlink<'a> {
5     pub filename: &'a [u8],
6 
7     pub buf: &'a mut [u8],
8 }
9 
10 impl<'a> ParseCommand<'a> for vFileReadlink<'a> {
11     #[inline(always)]
from_packet(buf: PacketBuf<'a>) -> Option<Self>12     fn from_packet(buf: PacketBuf<'a>) -> Option<Self> {
13         let (buf, body_range) = buf.into_raw_buf();
14         // TODO: rewrite to avoid panic
15         let (body, buf) = buf[body_range.start..].split_at_mut(body_range.end - body_range.start);
16 
17         if body.is_empty() {
18             return None;
19         }
20 
21         match body {
22             [b':', body @ ..] => {
23                 let filename = decode_hex_buf(body).ok()?;
24                 Some(vFileReadlink { filename, buf })
25             }
26             _ => None,
27         }
28     }
29 }
30