greppy/daemon/
protocol.rs1use crate::search::SearchResponse;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct Request {
6 pub id: String,
7 pub method: Method,
8}
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11#[serde(tag = "type", content = "params")]
12pub enum Method {
13 Search {
14 query: String,
15 project: String,
16 limit: usize,
17 },
18 Index {
19 project: String,
20 force: bool,
21 },
22 IndexWatch {
23 project: String,
24 },
25 Status,
26 List,
27 Forget {
28 project: String,
29 },
30 Stop,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct Response {
35 pub id: String,
36 pub result: ResponseResult,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(tag = "type", content = "data")]
41pub enum ResponseResult {
42 Search(SearchResponse),
43 Index {
44 project: String,
45 file_count: usize,
46 chunk_count: usize,
47 elapsed_ms: f64,
48 },
49 Status {
50 running: bool,
51 pid: u32,
52 projects: Vec<ProjectInfo>,
53 },
54 List {
55 projects: Vec<ProjectInfo>,
56 },
57 Forget {
58 project: String,
59 success: bool,
60 },
61 Stop {
62 success: bool,
63 },
64 Error {
65 message: String,
66 },
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct ProjectInfo {
71 pub path: String,
72 pub name: String,
73 pub chunk_count: usize,
74 pub watching: bool,
75}