2021-12-05 18:33:40 -05:00
|
|
|
use crate::error::{Error, Result};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
2021-12-05 19:14:14 -05:00
|
|
|
pub struct CloseCmd {
|
2021-12-05 18:33:40 -05:00
|
|
|
cmd: String,
|
|
|
|
id: String,
|
|
|
|
}
|
|
|
|
|
2021-12-05 19:14:14 -05:00
|
|
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
|
|
|
pub struct Close {
|
2021-12-11 16:48:59 -05:00
|
|
|
pub id: String,
|
2021-12-05 19:14:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<CloseCmd> for Result<Close> {
|
|
|
|
fn from(cc: CloseCmd) -> Result<Close> {
|
|
|
|
// ensure command is correct
|
|
|
|
if cc.cmd != "CLOSE" {
|
|
|
|
return Err(Error::CommandUnknownError);
|
|
|
|
} else {
|
|
|
|
return Ok(Close { id: cc.id });
|
2021-12-05 18:33:40 -05:00
|
|
|
}
|
|
|
|
}
|
2021-12-05 19:14:14 -05:00
|
|
|
}
|
2021-12-05 18:33:40 -05:00
|
|
|
|
2021-12-05 19:14:14 -05:00
|
|
|
impl Close {
|
2021-12-05 18:33:40 -05:00
|
|
|
pub fn get_id(&self) -> String {
|
|
|
|
self.id.clone()
|
|
|
|
}
|
|
|
|
}
|