use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct ApiResponse<T> {
pub success: bool,
pub data: Option<T>,
pub error: Option<String>,
}
impl<T> ApiResponse<T> {
pub fn success(data: T) -> Self {
Self {
success: true,
data: Some(data),
error: None,
}
}
pub fn error(message: String) -> Self {
Self {
success: false,
data: None,
error: Some(message),
}
}
}
#[derive(Serialize, Deserialize)]
pub struct DaemonStatus {
pub running: bool,
pub pid: Option<u32>,
pub config_path: String,
pub api_server: ApiServerInfo,
}
#[derive(Serialize, Deserialize)]
pub struct ApiServerInfo {
pub port: u16,
pub url: String,
}
#[derive(Deserialize)]
pub struct SnippetRequest {
pub shortcut: String,
pub snippet: String,
}
#[derive(Deserialize)]
pub struct GetSnippetRequest {
pub shortcut: String,
}
#[derive(Deserialize)]
pub struct DeleteSnippetRequest {
pub shortcut: String,
}