I think I might be sending the first command over the socket.
parent
41d5f980ef
commit
d56a7f32b6
@ -1,9 +1,35 @@
|
||||
use serde::ser::SerializeMap;
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
|
||||
pub struct Command {
|
||||
command: Vec<String>,
|
||||
request_id: Option<u64>,
|
||||
asynchronous: bool,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
pub fn new(command: Vec<String>) -> Self {
|
||||
Command { command: command }
|
||||
pub fn new(command: Vec<String>, request_id: Option<u64>) -> Self {
|
||||
Command {
|
||||
command,
|
||||
request_id,
|
||||
asynchronous: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Command {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let mut map = serializer.serialize_map(None)?;
|
||||
map.serialize_entry("command", &self.command)?;
|
||||
self.request_id
|
||||
.map(|reqid| map.serialize_entry("request_id", &reqid))
|
||||
.map_or(Ok(None), |x| x.map(Some))?;
|
||||
if self.asynchronous {
|
||||
map.serialize_entry("async", &self.asynchronous)?;
|
||||
}
|
||||
map.end()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue