aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/commands/_QCatchSyscalls.rs
blob: 26a27a1efd7d758710e59008cab720ec5e6eab78 (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
use super::prelude::*;

use crate::protocol::common::lists::ArgListHex;

#[derive(Debug)]
pub enum QCatchSyscalls<'a> {
    Disable,
    Enable(ArgListHex<'a>),
    EnableAll,
}

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

        match body {
            [b':', b'0'] => Some(QCatchSyscalls::Disable),
            [b':', b'1', b';', sysno @ ..] => {
                Some(QCatchSyscalls::Enable(ArgListHex::from_packet(sysno)?))
            }
            [b':', b'1'] => Some(QCatchSyscalls::EnableAll),
            _ => None,
        }
    }
}