-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split qTBuffer/QTBuffer, fix trace explanations
- Loading branch information
cczetier
committed
Jan 6, 2025
1 parent
943b7f4
commit 93a789d
Showing
4 changed files
with
59 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use super::prelude::*; | ||
|
||
#[derive(Debug)] | ||
pub struct qTBuffer<'a> { | ||
pub offset: u64, | ||
pub length: usize, | ||
pub data: &'a mut [u8] | ||
} | ||
|
||
impl<'a> ParseCommand<'a> for qTBuffer<'a> { | ||
#[inline(always)] | ||
fn from_packet(buf: PacketBuf<'a>) -> Option<Self> { | ||
let (buf, body_range) = buf.into_raw_buf(); | ||
let body = &buf[body_range]; | ||
match body { | ||
[b':', body @ ..] => { | ||
let mut req_opts = body.split(|b| *b == b','); | ||
let (offset, length) = (req_opts.next()?, req_opts.next()?); | ||
let offset = decode_hex(offset).ok()?; | ||
let length = decode_hex(length).ok()?; | ||
// Our response has to be a hex encoded buffer that fits within | ||
// our packet size, which means we actually have half as much space | ||
// as our slice would indicate. | ||
let (front, _back) = buf.split_at_mut(buf.len() / 2); | ||
Some(qTBuffer { offset, length, data: front }) | ||
}, | ||
_ => None | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters