1 use super::prelude::*;
2 
3 #[derive(Debug)]
4 pub struct QEnvironmentHexEncoded<'a> {
5     pub key: &'a [u8],
6     pub value: Option<&'a [u8]>,
7 }
8 
9 impl<'a> ParseCommand<'a> for QEnvironmentHexEncoded<'a> {
from_packet(buf: PacketBuf<'a>) -> Option<Self>10     fn from_packet(buf: PacketBuf<'a>) -> Option<Self> {
11         let body = buf.into_body();
12 
13         let (key, value) = match body {
14             [b':', keyval @ ..] => {
15                 let keyval = decode_hex_buf(keyval).ok()?;
16                 let mut keyval = keyval.splitn(2, |b| *b == b'=');
17                 let key = keyval.next()?;
18                 let value = match keyval.next()? {
19                     [] => None,
20                     s => Some(s),
21                 };
22                 (key, value)
23             }
24             _ => return None,
25         };
26 
27         Some(QEnvironmentHexEncoded { key, value })
28     }
29 }
30