aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/commands/_h_upcase.rs
blob: f7bb9ed16512a2e78f8cfab3650466a29a9b0bfe (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
30
31
32
33
use super::prelude::*;
use crate::protocol::common::thread_id::ThreadId;

#[derive(Debug)]
pub enum Op {
    StepContinue,
    Other,
}

#[derive(Debug)]
pub struct H {
    pub kind: Op,
    pub thread: ThreadId,
}

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

        let kind = match body[0] {
            b'g' => Op::Other,
            b'c' => Op::StepContinue,
            _ => return None,
        };
        let thread: ThreadId = body[1..].try_into().ok()?;

        Some(H { kind, thread })
    }
}