@@ -18,8 +18,6 @@ pub struct Request {
1818 #[serde(skip)]
1919 pub back_ch: Option<Sender<Result<Response>>>,
2020 pub seq: u64,
21− #[serde(rename = "type")]
22− pub msg_type: String,
2321 pub command: String,
2422 pub arguments: Option<Value>,
2523}
@@ -27,8 +25,6 @@ pub struct Request {
2725#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
2826pub struct Response {
2927 // seq is omitted as unused and is not sent by some implementations
30− #[serde(rename = "type")]
31− pub msg_type: String,
3228 pub request_seq: u64,
3329 pub success: bool,
3430 pub command: String,
@@ -39,14 +35,12 @@ pub struct Response {
3935#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
4036pub struct Event {
4137 // seq is omitted as unused and is not sent by some implementations
42− #[serde(rename = "type")]
43− pub msg_type: String,
4438 pub event: String,
4539 pub body: Option<Value>,
4640}
4741
4842#[derive(Debug, Clone, Deserialize, Serialize)]
49−#[serde(untagged)]
43+#[serde(tag = "type", rename_all = "camelCase")]
5044pub enum Payload {
5145 // type = "event"
5246 Event(Event),
@@ -135,7 +129,7 @@ impl Transport {
135129 server_stdin: &mut Box<dyn AsyncWrite + Unpin + Send>,
136130 req: Request,
137131 ) -> Result<()> {
138− let json = serde_json::to_string(&req)?;
132+ let json = serde_json::to_string(&Payload::Request(req.clone()))?;
139133 if let Some(back) = req.back_ch {
140134 self.pending_requests.lock().await.insert(req.seq, back);
141135 }