keyhook_model/
lib.rs

1//! **Shared data models** consumed by both the Yew (frontend) and
2//! Tauri (backend) crates.
3
4use serde::{Deserialize, Serialize};
5
6/// HTTP verbs supported by KeyHook.
7#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
8#[serde(rename_all = "UPPERCASE")]
9pub enum HttpMethod {
10    GET,
11    POST,
12    PUT,
13    DELETE,
14    PATCH,
15}
16
17/// A mapping from a *global shortcut* to a *webhook endpoint*.
18#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
19pub struct HookRule {
20    /// `None` when created on the client; a `Uuid` is assigned server-side.
21    pub id: Option<String>,
22    /// Example: `"Ctrl+Shift+F"`.
23    pub hotkey: String,
24    pub method: HttpMethod,
25    pub url: String,
26    /// Optional JSON request body.
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub body: Option<String>,
29    /// Whether the rule is active. Default: `true`.
30    #[serde(default = "enabled_true")]
31    pub enabled: bool,
32}
33
34#[inline]
35fn enabled_true() -> bool {
36    true
37}