aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/commands/_vFile_setfs.rs
blob: 41a3100b4abe4a88d3caec16eba95603993d3f23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::prelude::*;

use crate::target::ext::host_io::FsKind;

#[derive(Debug)]
pub struct vFileSetfs {
    pub fs: FsKind,
}

impl<'a> ParseCommand<'a> for vFileSetfs {
    #[inline(always)]
    fn from_packet(buf: PacketBuf<'a>) -> Option<Self> {
        let body = buf.into_body();
        if body.is_empty() {
            return None;
        }

        match body {
            [b':', body @ ..] => {
                let fs = match crate::common::Pid::new(decode_hex(body).ok()?) {
                    None => FsKind::Stub,
                    Some(pid) => FsKind::Pid(pid),
                };
                Some(vFileSetfs { fs })
            }
            _ => None,
        }
    }
}