gdbstub 0.7.10

An implementation of the GDB Remote Serial Protocol in Rust
Documentation
use super::prelude::*;

#[derive(Debug)]
pub struct qWasmGlobal<'a> {
    pub frame: usize,
    pub global: usize,
    pub buf: &'a mut [u8],
}

impl<'a> ParseCommand<'a> for qWasmGlobal<'a> {
    #[inline(always)]
    fn from_packet(buf: PacketBuf<'a>) -> Option<Self> {
        let (buf, body_range) = buf.into_raw_buf();
        let body = buf.get(body_range.start..body_range.end)?;

        if body.is_empty() || body[0] != b':' {
            return None;
        }
        let mut parts = body[1..].split(|b| *b == b';');
        let frame = parts.next()?;
        let frame = str::from_utf8(frame).ok()?.parse::<usize>().ok()?;
        let global = parts.next()?;
        let global = str::from_utf8(global).ok()?.parse::<usize>().ok()?;
        if parts.next().is_some() {
            // Too many parameters.
            return None;
        }

        Some(qWasmGlobal {
            frame,
            global,
            buf,
        })
    }
}