travsr_plugin_protocol/
types.rs1use crate::ffi_marker::FfiMarker;
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4use travsr_core::{Edge, Node};
5
6pub const PROTOCOL_VERSION: u32 = 1;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ParseRequest {
11 pub path: PathBuf,
13 pub vname_path: String,
16 pub corpus: String,
17 pub package: String,
18 pub source: Option<Vec<u8>>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize, Default)]
23pub struct ParseResponse {
24 pub nodes: Vec<Node>,
25 pub edges: Vec<Edge>,
26 pub ffi_markers: Vec<FfiMarker>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct InvokeRequest {
31 pub root: PathBuf,
32 #[serde(default)]
36 pub corpus: String,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, Default)]
40pub struct InvokeResponse {
41 pub nodes: Vec<Node>,
42 pub edges: Vec<Edge>,
43}
44
45impl InvokeResponse {
46 pub fn unsupported() -> Self {
47 Self::default()
48 }
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct HandshakeRequest {
53 pub daemon_protocol_version: u32,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct HandshakeResponse {
58 pub protocol_version: u32,
59 pub plugin_version: String,
60 pub language: String,
62 pub extensions: Vec<String>,
63 pub supports_phase_b: bool,
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(tag = "type", rename_all = "snake_case")]
68pub enum PluginRequest {
69 Handshake(HandshakeRequest),
70 Parse(ParseRequest),
71 Invoke(InvokeRequest),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(tag = "type", rename_all = "snake_case")]
76pub enum PluginResponse {
77 Handshake(HandshakeResponse),
78 Parse(ParseResponse),
79 Invoke(InvokeResponse),
80 Error(PluginError),
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
84pub struct PluginError {
85 pub file: String,
86 pub message: String,
87}