aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/commands/_qXfer_exec_file.rs
blob: efcb8bc46db605f07a50e5bb08ebb6b6777b63fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use super::prelude::*;
use crate::common::Pid;
use crate::protocol::common::qxfer::ParseAnnex;
use crate::protocol::common::qxfer::QXferReadBase;

pub type qXferExecFileRead<'a> = QXferReadBase<'a, ExecFileAnnex>;

#[derive(Debug)]
pub struct ExecFileAnnex {
    pub pid: Option<Pid>,
}

impl<'a> ParseAnnex<'a> for ExecFileAnnex {
    #[inline(always)]
    fn from_buf(buf: &[u8]) -> Option<Self> {
        let pid = match buf {
            [] => None,
            buf => Some(Pid::new(decode_hex(buf).ok()?)?),
        };

        Some(ExecFileAnnex { pid })
    }
}