• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use super::prelude::*;
2 use crate::target::ext::host_io::HostIoOpenFlags;
3 use crate::target::ext::host_io::HostIoOpenMode;
4 
5 #[derive(Debug)]
6 pub struct vFileOpen<'a> {
7     pub filename: &'a [u8],
8     pub flags: HostIoOpenFlags,
9     pub mode: HostIoOpenMode,
10 }
11 
12 impl<'a> ParseCommand<'a> for vFileOpen<'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 filename = decode_hex_buf(body.next()?).ok()?;
24                 let flags = HostIoOpenFlags::from_bits(decode_hex(body.next()?).ok()?)?;
25                 let mode = HostIoOpenMode::from_bits(decode_hex(body.next()?).ok()?)?;
26                 Some(vFileOpen {
27                     filename,
28                     flags,
29                     mode,
30                 })
31             }
32             _ => None,
33         }
34     }
35 }
36