blob: 32f45f1afca77874fbf4374152aa96fb205942c4 (
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
|
use super::prelude::*;
use crate::protocol::common::hex::decode_bin_buf;
#[derive(Debug)]
pub struct vFilePwrite<'a> {
pub fd: u32,
pub offset: &'a [u8],
pub data: &'a [u8],
}
impl<'a> ParseCommand<'a> for vFilePwrite<'a> {
#[inline(always)]
fn from_packet(buf: PacketBuf<'a>) -> Option<Self> {
let body = buf.into_body();
if body.is_empty() {
return None;
}
match body {
[b':', body @ ..] => {
let mut body = body.splitn_mut(3, |b| *b == b',');
let fd = decode_hex(body.next()?).ok()?;
let offset = decode_hex_buf(body.next()?).ok()?;
let data = decode_bin_buf(body.next()?)?;
Some(vFilePwrite { fd, offset, data })
}
_ => None,
}
}
}
|