use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct DoubleClickAction {
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "x")]
pub x: i32,
#[serde(rename = "y")]
pub y: i32,
#[serde(rename = "keys", deserialize_with = "Option::deserialize")]
pub keys: Option<Vec<String>>,
}
impl DoubleClickAction {
pub fn new(r#type: Type, x: i32, y: i32, keys: Option<Vec<String>>) -> DoubleClickAction {
DoubleClickAction { r#type, x, y, keys }
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "double_click")]
DoubleClick,
}
impl Default for Type {
fn default() -> Type {
Self::DoubleClick
}
}
impl std::fmt::Display for DoubleClickAction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}