use serde::{Deserialize, Serialize};
use crate::protocol::JsonMessage;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(
tag = "op",
rename = "unsubscribeParameterUpdates",
rename_all = "camelCase"
)]
pub struct UnsubscribeParameterUpdates {
pub parameter_names: Vec<String>,
}
impl UnsubscribeParameterUpdates {
pub fn new(names: impl IntoIterator<Item = impl Into<String>>) -> Self {
Self {
parameter_names: names.into_iter().map(Into::into).collect(),
}
}
}
impl JsonMessage for UnsubscribeParameterUpdates {}
#[cfg(test)]
mod tests {
use super::*;
fn message() -> UnsubscribeParameterUpdates {
UnsubscribeParameterUpdates {
parameter_names: vec!["param1".to_string(), "param2".to_string()],
}
}
#[test]
fn test_encode() {
insta::assert_json_snapshot!(message());
}
#[test]
fn test_roundtrip() {
let orig = message();
let buf = orig.to_string();
let parsed: UnsubscribeParameterUpdates = serde_json::from_str(&buf).unwrap();
assert_eq!(parsed, orig);
}
}