feat: parse subscription close requests from websockets

This commit is contained in:
Greg Heartsfield
2021-12-05 17:33:40 -06:00
parent e7d0ab1aca
commit 35ceb7cb64
5 changed files with 35 additions and 6 deletions
+22
View File
@@ -0,0 +1,22 @@
use crate::error::{Error, Result};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct Close {
cmd: String,
id: String,
}
impl Close {
pub fn parse(json: &str) -> Result<Close> {
let c: Close = serde_json::from_str(json)?; //.map_err(|e| Error::JsonParseFailed(e));
if c.cmd != "CLOSE" {
return Err(Error::CloseParseFailed);
}
return Ok(c);
}
pub fn get_id(&self) -> String {
self.id.clone()
}
}