1use serde::{ser::SerializeMap, Deserialize, Serialize, Serializer};
2use std::num::NonZeroUsize;
3
4mod request;
5mod response;
6mod variables_arguments;
7
8pub use self::{request::Request, response::Response, variables_arguments::VariablesArguments};
9
10#[derive(Clone, Debug, Serialize)]
11pub struct DebugCapability {
12 #[serde(rename = "supportsCompletionsRequest")]
13 pub supports_completions_request: bool,
14 #[serde(rename = "supportsConditionalBreakpoints")]
15 pub supports_conditional_breakpoints: bool,
16 #[serde(rename = "supportsConfigurationDoneRequest")]
17 pub supports_configuration_done_request: bool,
18 #[serde(rename = "supportsDebuggerProperties")]
19 pub supports_debugger_properties: bool,
20 #[serde(rename = "supportsDelayedStackTraceLoading")]
21 pub supports_delayed_stack_trace_loading: bool,
22 #[serde(rename = "supportsEvaluateForHovers")]
23 pub supports_evaluate_for_hovers: bool,
24 #[serde(rename = "supportsExceptionInfoRequest")]
25 pub supports_exception_info_request: bool,
26 #[serde(rename = "supportsExceptionOptions")]
27 pub supports_exception_options: bool,
28 #[serde(rename = "supportsFunctionBreakpoints")]
29 pub supports_function_breakpoints: bool,
30 #[serde(rename = "supportsHitConditionalBreakpoints")]
31 pub supports_hit_conditional_breakpoints: bool,
32 #[serde(rename = "supportsLogPoints")]
33 pub supports_log_points: bool,
34 #[serde(rename = "supportsModulesRequest")]
36 pub supports_modules_request: bool,
37 #[serde(rename = "supportsSetExpression")]
38 pub supports_set_expression: bool,
39 #[serde(rename = "supportsSetVariable")]
40 pub supports_set_variable: bool,
41 #[serde(rename = "supportsVariablePaging")]
43 pub supports_variable_paging: bool,
44 #[serde(rename = "supportsValueFormattingOptions")]
46 pub supports_value_formatting_options: bool,
47 #[serde(rename = "supportsTerminateDebuggee")]
48 pub supports_terminate_debuggee: bool,
49 #[serde(rename = "supportsGotoTargetsRequest")]
50 pub supports_goto_targets_request: bool,
51 #[serde(rename = "supportsClipboardContext")]
52 pub supports_clipboard_context: bool,
53 #[serde(rename = "supportsStepInTargetsRequest")]
54 pub supports_step_in_targets_request: bool,
55 #[serde(rename = "exceptionBreakpointFilters")]
56 pub exception_breakpoint_filters: Vec<ExceptionBreakpointFilter>,
57}
58
59#[derive(Clone, Debug, Serialize)]
60pub struct ExceptionBreakpointFilter {
61 pub filter: String,
62 pub label: String,
63 pub default: bool,
64}
65
66impl Default for DebugCapability {
67 fn default() -> Self {
68 Self {
69 supports_completions_request: true,
70 supports_conditional_breakpoints: true,
71 supports_configuration_done_request: true,
72 supports_debugger_properties: true,
73 supports_delayed_stack_trace_loading: true,
74 supports_evaluate_for_hovers: true,
75 supports_exception_info_request: true,
76 supports_exception_options: true,
77 supports_function_breakpoints: true,
78 supports_hit_conditional_breakpoints: true,
79 supports_log_points: true,
80 supports_modules_request: true,
81 supports_set_expression: true,
82 supports_set_variable: true,
83 supports_variable_paging: true,
84 supports_value_formatting_options: true,
85 supports_terminate_debuggee: true,
86 supports_goto_targets_request: true,
87 supports_clipboard_context: true,
88 supports_step_in_targets_request: true,
89 exception_breakpoint_filters: vec![],
90 }
91 }
92}
93
94#[derive(Clone, Debug, Serialize)]
95pub struct VariablesResponseBody {
96 pub variables: Vec<Variable>,
97}
98
99impl<V: Into<Variable>> FromIterator<V> for VariablesResponseBody {
100 fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self {
101 VariablesResponseBody { variables: iter.into_iter().map(|v| v.into()).collect() }
102 }
103}
104
105#[derive(Clone, Debug, Serialize)]
117pub struct Variable {
118 pub name: String,
120 pub value: String,
128 #[serde(rename = "type")]
133 pub typing: String,
134 #[serde(rename = "evaluateName")]
137 pub evaluate_name: String,
138 #[serde(rename = "variablesReference")]
143 pub variables_reference: usize,
144 #[serde(rename = "namedVariables")]
148 pub named_variables: usize,
149 #[serde(rename = "indexedVariables")]
153 pub indexed_variables: usize,
154 #[serde(rename = "memoryReference")]
160 pub memory_reference: String,
161}
162
163#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
164pub struct ModulesArguments {
165 #[serde(rename = "startModule")]
169 pub start: usize,
170 #[serde(rename = "moduleCount")]
174 pub count: Option<NonZeroUsize>,
175}
176#[derive(Clone, Debug, Serialize, Deserialize)]
177pub struct ModulesResponseBody {
178 pub modules: Vec<Module>,
179 #[serde(rename = "totalModules")]
180 pub total_modules: usize,
181}
182
183impl<M: Into<Module>> FromIterator<M> for ModulesResponseBody {
184 fn from_iter<T: IntoIterator<Item = M>>(iter: T) -> Self {
185 let mut out = ModulesResponseBody { modules: vec![], total_modules: 0 };
186 for m in iter.into_iter().map(|m| m.into()) {
187 out.modules.push(m);
188 out.total_modules += 1;
189 }
190 out
191 }
192}
193
194#[derive(Clone, Debug, Serialize, Deserialize)]
196pub struct Module {
197 pub id: u32,
199 pub name: String,
201 pub path: String,
203 #[serde(rename = "isOptimized")]
205 pub is_optimized: bool,
206 #[serde(rename = "isUserCode")]
209 pub is_user_code: bool,
210 pub version: String,
212}
213
214#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
215#[serde(rename_all = "lowercase")]
216pub enum VariableFilter {
217 Indexed,
218 Named,
219}
220
221#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
222#[serde(rename_all = "camelCase")]
223pub struct ValueFormat {
224 hex: Option<bool>,
226}
227
228#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
230#[serde(rename_all = "camelCase")]
231pub enum DataBreakpointAccessType {
232 Read,
233 Write,
234 ReadWrite,
235}
236
237#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
239#[serde(rename_all = "camelCase")]
240pub enum SteppingGranularity {
241 Statement,
247 Line,
249 Instruction,
251}
252
253#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
259pub struct DisconnectArguments {
260 pub restart: bool,
263
264 #[serde(default, rename = "terminateDebuggee")]
269 pub terminate_debuggee: bool,
270
271 #[serde(default, rename = "suspendDebuggee")]
276 pub suspend_debuggee: bool,
277}