use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
pub struct Screenshot {
pub png_bytes: Vec<u8>,
pub logical_size: (u32, u32),
pub physical_size: (u32, u32),
pub scale_factor: f32,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum Action {
Wait { seconds: f32 },
MouseMove { x: i32, y: i32 },
Click { x: i32, y: i32, button: MouseButton },
DoubleClick { x: i32, y: i32 },
Drag {
from_x: i32,
from_y: i32,
to_x: i32,
to_y: i32,
},
Scroll {
x: i32,
y: i32,
direction: ScrollDir,
clicks: i32,
},
Type { text: String },
Hotkey { keys: String },
HoldKey { key: String, seconds: f32 },
Screenshot,
ActivateApp { app: String },
Finished { content: String },
CallUser { reason: String },
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum MouseButton {
Left,
Right,
Middle,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ScrollDir {
Up,
Down,
Left,
Right,
}
#[derive(Debug, Clone)]
pub struct ActionSpec {
pub signature: &'static str,
pub note: Option<&'static str>,
}
impl ActionSpec {
pub const fn new(signature: &'static str) -> Self {
Self {
signature,
note: None,
}
}
pub const fn with_note(signature: &'static str, note: &'static str) -> Self {
Self {
signature,
note: Some(note),
}
}
pub fn render(&self) -> String {
match self.note {
Some(n) => format!("{} {}", self.signature, n),
None => self.signature.to_owned(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct ExecCtx {
pub screen_w: u32,
pub screen_h: u32,
pub scale_factor: f32,
pub factors: [u32; 2],
}
#[derive(Debug, Clone)]
pub struct ParsedAction {
pub thought: String,
pub action_type: String,
pub raw_args: std::collections::BTreeMap<String, String>,
pub start: Option<(f32, f32)>,
pub end: Option<(f32, f32)>,
}