Skip to main content

dap/
types.rs

1use std::{collections::HashMap, sync::Arc};
2
3#[cfg(feature = "integration_testing")]
4use fake::{Dummy, Fake, Faker, RngExt};
5use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8#[derive(Deserialize, Serialize, Debug, Default, Clone)]
9#[serde(rename_all = "camelCase")]
10#[cfg_attr(feature = "integration_testing", derive(Dummy))]
11pub struct ExceptionBreakpointsFilter {
12    /// The internal ID of the filter option. This value is passed to the
13    /// `setExceptionBreakpoints` request.
14    pub filter: String,
15    /// The name of the filter option. This is shown in the UI.
16    pub label: String,
17    /// A help text providing additional information about the exception filter.
18    /// This string is typically shown as a hover and can be translated.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub description: Option<String>,
21    /// Initial value of the filter option. If not specified a value false is
22    /// assumed.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub default: Option<bool>,
25    /// Controls whether a condition can be specified for this filter option. If
26    /// false or missing, a condition can not be set.
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub supports_condition: Option<bool>,
29    /// A help text providing information about the condition. This string is shown
30    /// as the placeholder text for a text box and can be translated.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub condition_description: Option<String>,
33}
34
35#[derive(Deserialize, Serialize, Debug, Clone)]
36#[serde(rename_all = "camelCase")]
37#[cfg_attr(feature = "integration_testing", derive(Dummy))]
38pub enum ColumnDescriptorType {
39    String,
40    Number,
41    Boolean,
42    UnixTimestampUTC,
43}
44
45#[derive(Deserialize, Serialize, Debug, Default, Clone)]
46#[serde(rename_all = "camelCase")]
47#[cfg_attr(feature = "integration_testing", derive(Dummy))]
48pub struct ColumnDescriptor {
49    /// Name of the attribute rendered in this column.
50    pub attribute_name: String,
51    /// Header UI label of column.
52    pub label: String,
53    /// Format to use for the rendered values in this column. TBD how the format
54    /// strings looks like.
55    pub format: String,
56    /// Datatype of values in this column. Defaults to `string` if not specified.
57    /// Values: 'string', 'number', 'bool', 'unixTimestampUTC'
58    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
59    pub column_descriptor_type: Option<ColumnDescriptorType>,
60    /// Width of this column in characters (hint only).
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub width: Option<i64>,
63}
64
65#[derive(Deserialize, Serialize, Debug, Clone)]
66#[cfg_attr(feature = "integration_testing", derive(Dummy))]
67pub enum ChecksumAlgorithm {
68    MD5,
69    SHA1,
70    SHA256,
71    #[serde(rename = "timestamp")]
72    Timestamp,
73}
74
75#[derive(Deserialize, Serialize, Debug, Default, Clone)]
76#[serde(rename_all = "camelCase")]
77#[cfg_attr(feature = "integration_testing", derive(Dummy))]
78pub struct Capabilities {
79    /// The debug adapter supports the `configurationDone` request.
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub supports_configuration_done_request: Option<bool>,
82    /// The debug adapter supports function breakpoints.
83    #[serde(skip_serializing_if = "Option::is_none")]
84    pub supports_function_breakpoints: Option<bool>,
85    /// The debug adapter supports conditional breakpoints.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub supports_conditional_breakpoints: Option<bool>,
88    /// The debug adapter supports breakpoints that break execution after a
89    /// specified i64 of hits.
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub supports_hit_conditional_breakpoints: Option<bool>,
92    /// The debug adapter supports a (side effect free) `evaluate` request for data
93    /// hovers.
94    #[serde(skip_serializing_if = "Option::is_none")]
95    pub supports_evaluate_for_hovers: Option<bool>,
96    /// Available exception filter options for the `setExceptionBreakpoints`
97    /// request.
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub exception_breakpoint_filters: Option<Vec<ExceptionBreakpointsFilter>>,
100    /// The debug adapter supports stepping back via the `stepBack` and
101    /// `reverseContinue` requests.
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub supports_step_back: Option<bool>,
104    /// The debug adapter supports setting a variable to a value.
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub supports_set_variable: Option<bool>,
107    /// The debug adapter supports restarting a frame.
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub supports_restart_frame: Option<bool>,
110    /// The debug adapter supports the `gotoTargets` request.
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub supports_goto_targets_request: Option<bool>,
113    /// The debug adapter supports the `stepInTargets` request.
114    #[serde(skip_serializing_if = "Option::is_none")]
115    pub supports_step_in_targets_request: Option<bool>,
116    /// The debug adapter supports the `completions` request.
117    #[serde(skip_serializing_if = "Option::is_none")]
118    pub supports_completions_request: Option<bool>,
119    /// The set of characters that should trigger completion in a REPL. If not
120    /// specified, the UI should assume the `.` character.
121    #[serde(skip_serializing_if = "Option::is_none")]
122    pub completion_trigger_characters: Option<Vec<String>>,
123    /// The debug adapter supports the `modules` request.
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub supports_modules_request: Option<bool>,
126    /// The set of additional module information exposed by the debug adapter.
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub additional_module_columns: Option<Vec<ColumnDescriptor>>,
129    /// Checksum algorithms supported by the debug adapter.
130    #[serde(skip_serializing_if = "Option::is_none")]
131    pub supported_checksum_algorithms: Option<Vec<ChecksumAlgorithm>>,
132    /// The debug adapter supports the `restart` request. In this case a client
133    /// should not implement `restart` by terminating and relaunching the adapter
134    /// but by calling the `restart` request.
135    #[serde(skip_serializing_if = "Option::is_none")]
136    pub supports_restart_request: Option<bool>,
137    /// The debug adapter supports `exceptionOptions` on the
138    /// `setExceptionBreakpoints` request.
139    #[serde(skip_serializing_if = "Option::is_none")]
140    pub supports_exception_options: Option<bool>,
141    /// The debug adapter supports a `format` attribute on the `stackTrace`,
142    /// `variables`, and `evaluate` requests.
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub supports_value_formatting_options: Option<bool>,
145    /// The debug adapter supports the `exceptionInfo` request.
146    #[serde(skip_serializing_if = "Option::is_none")]
147    pub supports_exception_info_request: Option<bool>,
148    /// The debug adapter supports the `terminateDebuggee` attribute on the
149    /// `disconnect` request.
150    #[serde(skip_serializing_if = "Option::is_none")]
151    pub support_terminate_debuggee: Option<bool>,
152    /// The debug adapter supports the `suspendDebuggee` attribute on the
153    /// `disconnect` request.
154    #[serde(skip_serializing_if = "Option::is_none")]
155    pub support_suspend_debuggee: Option<bool>,
156    /// The debug adapter supports the delayed loading of parts of the stack, which
157    /// requires that both the `startFrame` and `levels` arguments and the
158    /// `totalFrames` result of the `stackTrace` request are supported.
159    #[serde(skip_serializing_if = "Option::is_none")]
160    pub supports_delayed_stack_trace_loading: Option<bool>,
161    /// The debug adapter supports the `loadedSources` request.
162    #[serde(skip_serializing_if = "Option::is_none")]
163    pub supports_loaded_sources_request: Option<bool>,
164    /// The debug adapter supports log points by interpreting the `logMessage`
165    /// attribute of the `SourceBreakpoint`.
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub supports_log_points: Option<bool>,
168    /// The debug adapter supports the `terminateThreads` request.
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub supports_terminate_threads_request: Option<bool>,
171    /// The debug adapter supports the `setExpression` request.
172    #[serde(skip_serializing_if = "Option::is_none")]
173    pub supports_set_expression: Option<bool>,
174    /// The debug adapter supports the `terminate` request.
175    #[serde(skip_serializing_if = "Option::is_none")]
176    pub supports_terminate_request: Option<bool>,
177    /// The debug adapter supports data breakpoints.
178    #[serde(skip_serializing_if = "Option::is_none")]
179    pub supports_data_breakpoints: Option<bool>,
180    /// The debug adapter supports the `readMemory` request.
181    #[serde(skip_serializing_if = "Option::is_none")]
182    pub supports_read_memory_request: Option<bool>,
183    /// The debug adapter supports the `writeMemory` request.
184    #[serde(skip_serializing_if = "Option::is_none")]
185    pub supports_write_memory_request: Option<bool>,
186    /// The debug adapter supports the `disassemble` request.
187    #[serde(skip_serializing_if = "Option::is_none")]
188    pub supports_disassemble_request: Option<bool>,
189    /// The debug adapter supports the `cancel` request.
190    #[serde(skip_serializing_if = "Option::is_none")]
191    pub supports_cancel_request: Option<bool>,
192    /// The debug adapter supports the `breakpointLocations` request.
193    #[serde(skip_serializing_if = "Option::is_none")]
194    pub supports_breakpoint_locations_request: Option<bool>,
195    /// The debug adapter supports the `clipboard` context value in the `evaluate`
196    /// request.
197    #[serde(skip_serializing_if = "Option::is_none")]
198    pub supports_clipboard_context: Option<bool>,
199    /// The debug adapter supports stepping granularities (argument `granularity`)
200    /// for the stepping requests.
201    #[serde(skip_serializing_if = "Option::is_none")]
202    pub supports_stepping_granularity: Option<bool>,
203    /// The debug adapter supports adding breakpoints based on instruction
204    /// references.
205    #[serde(skip_serializing_if = "Option::is_none")]
206    pub supports_instruction_breakpoints: Option<bool>,
207    /// The debug adapter supports `filterOptions` as an argument on the
208    /// `setExceptionBreakpoints` request.
209    #[serde(skip_serializing_if = "Option::is_none")]
210    pub supports_exception_filter_options: Option<bool>,
211    /// The debug adapter supports the `singleThread` property on the execution
212    /// requests (`continue`, `next`, `stepIn`, `stepOut`, `reverseContinue`,
213    /// `stepBack`).
214    #[serde(skip_serializing_if = "Option::is_none")]
215    pub supports_single_thread_execution_requests: Option<bool>,
216}
217
218#[derive(Deserialize, Serialize, Debug, Default, Clone)]
219pub struct CustomValue(pub Value);
220
221#[cfg(feature = "integration_testing")]
222struct ValueFaker;
223
224#[cfg(feature = "integration_testing")]
225impl Dummy<ValueFaker> for CustomValue {
226    fn dummy_with_rng<R: RngExt + ?Sized>(_: &ValueFaker, rng: &mut R) -> Self {
227        CustomValue(match rng.random_range(0..=5) {
228            1 => Value::Bool(rng.random()),
229            2 => Value::Number(serde_json::Number::from_f64(rng.random()).unwrap()),
230            3 => Value::String(Faker.fake::<String>()),
231            _ => Value::Null,
232        })
233    }
234}
235
236/// A Source is a descriptor for source code.
237///
238/// It is returned from the debug adapter as part of a StackFrame and it is used by clients when
239/// specifying breakpoints.
240///
241/// Specification: [Source](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source)
242#[derive(Deserialize, Serialize, Debug, Default, Clone)]
243#[serde(rename_all = "camelCase")]
244#[cfg_attr(feature = "integration_testing", derive(Dummy))]
245pub struct Source {
246    /// The short name of the source. Every source returned from the debug adapter
247    /// has a name.
248    /// When sending a source to the debug adapter this name is optional.
249    #[serde(skip_serializing_if = "Option::is_none")]
250    pub name: Option<String>,
251    /// The path of the source to be shown in the UI.
252    /// It is only used to locate and load the content of the source if no
253    /// `sourceReference` is specified (or its value is 0).
254    #[serde(skip_serializing_if = "Option::is_none")]
255    pub path: Option<String>,
256    /// If the value > 0 the contents of the source must be retrieved through the
257    /// `source` request (even if a path is specified).
258    /// Since a `sourceReference` is only valid for a session, it can not be used
259    /// to persist a source.
260    /// The value should be less than or equal to 2147483647 (2^31-1).
261    #[serde(skip_serializing_if = "Option::is_none")]
262    pub source_reference: Option<i32>,
263    /// A hint for how to present the source in the UI.
264    /// A value of `deemphasize` can be used to indicate that the source is not
265    /// available or that it is skipped on stepping.
266    #[serde(skip_serializing_if = "Option::is_none")]
267    pub presentation_hint: Option<PresentationHint>,
268    /// The origin of this source. For example, 'internal module', 'inlined content
269    /// from source map', etc.
270    #[serde(skip_serializing_if = "Option::is_none")]
271    pub origin: Option<String>,
272    /// A list of sources that are related to this source. These may be the source
273    /// that generated this source.
274    #[serde(skip_serializing_if = "Option::is_none")]
275    pub sources: Option<Vec<Source>>,
276    /// Additional data that a debug adapter might want to loop through the client.
277    /// The client should leave the data intact and persist it across sessions. The
278    /// client should not interpret the data.
279    #[cfg_attr(feature = "integration_testing", dummy(faker = "ValueFaker"))]
280    #[serde(skip_serializing_if = "Option::is_none")]
281    pub adapter_data: Option<CustomValue>,
282    /// The checksums associated with this file.
283    #[serde(skip_serializing_if = "Option::is_none")]
284    pub checksums: Option<Vec<Checksum>>,
285}
286
287#[derive(Deserialize, Serialize, Debug, Default, Clone)]
288#[serde(rename_all = "camelCase")]
289#[cfg_attr(feature = "integration_testing", derive(Dummy))]
290pub struct SourceBreakpoint {
291    /// The source line of the breakpoint or logpoint.
292    pub line: i64,
293    /// Start position within source line of the breakpoint or logpoint. It is
294    /// measured in UTF-16 code units and the client capability `columnsStartAt1`
295    /// determines whether it is 0- or 1-based.
296    #[serde(skip_serializing_if = "Option::is_none")]
297    pub column: Option<i64>,
298    /// The expression for conditional breakpoints.
299    /// It is only honored by a debug adapter if the corresponding capability
300    /// `supportsConditionalBreakpoints` is true.
301    #[serde(skip_serializing_if = "Option::is_none")]
302    pub condition: Option<String>,
303    /// The expression that controls how many hits of the breakpoint are ignored.
304    /// The debug adapter is expected to interpret the expression as needed.
305    /// The attribute is only honored by a debug adapter if the corresponding
306    /// capability `supportsHitConditionalBreakpoints` is true.
307    #[serde(skip_serializing_if = "Option::is_none")]
308    pub hit_condition: Option<String>,
309    /// If this attribute exists and is non-empty, the debug adapter must not
310    /// 'break' (stop)
311    /// but log the message instead. Expressions within `{}` are interpolated.
312    /// The attribute is only honored by a debug adapter if the corresponding
313    /// capability `supportsLogPoints` is true.
314    #[serde(skip_serializing_if = "Option::is_none")]
315    pub log_message: Option<String>,
316}
317
318/// Information about a breakpoint created in setBreakpoints, setFunctionBreakpoints,
319/// setInstructionBreakpoints, or setDataBreakpoints requests.
320#[derive(Deserialize, Serialize, Debug, Default, Clone)]
321#[serde(rename_all = "camelCase")]
322#[cfg_attr(feature = "integration_testing", derive(Dummy))]
323pub struct Breakpoint {
324    /// The identifier for the breakpoint. It is needed if breakpoint events are
325    /// used to update or remove breakpoints.
326    #[serde(skip_serializing_if = "Option::is_none")]
327    pub id: Option<i64>,
328    /// If true, the breakpoint could be set (but not necessarily at the desired
329    /// location).
330    pub verified: bool,
331    /// A message about the state of the breakpoint.
332    /// This is shown to the user and can be used to explain why a breakpoint could
333    /// not be verified.
334    #[serde(skip_serializing_if = "Option::is_none")]
335    pub message: Option<String>,
336    /// The source where the breakpoint is located.
337    #[serde(skip_serializing_if = "Option::is_none")]
338    pub source: Option<Source>,
339    /// The start line of the actual range covered by the breakpoint.
340    #[serde(skip_serializing_if = "Option::is_none")]
341    pub line: Option<i64>,
342    /// Start position of the source range covered by the breakpoint. It is
343    /// measured in UTF-16 code units and the client capability `columnsStartAt1`
344    /// determines whether it is 0- or 1-based.
345    #[serde(skip_serializing_if = "Option::is_none")]
346    pub column: Option<i64>,
347    /// The end line of the actual range covered by the breakpoint.
348    #[serde(skip_serializing_if = "Option::is_none")]
349    pub end_line: Option<i64>,
350    /// End position of the source range covered by the breakpoint. It is measured
351    /// in UTF-16 code units and the client capability `columnsStartAt1` determines
352    /// whether it is 0- or 1-based.
353    /// If no end line is given, then the end column is assumed to be in the start
354    /// line.
355    #[serde(skip_serializing_if = "Option::is_none")]
356    pub end_column: Option<i64>,
357    /// A memory reference to where the breakpoint is set.
358    #[serde(skip_serializing_if = "Option::is_none")]
359    pub instruction_reference: Option<String>,
360    /// The offset from the instruction reference.
361    /// This can be negative.
362    #[serde(skip_serializing_if = "Option::is_none")]
363    pub offset: Option<i64>,
364}
365
366#[derive(Deserialize, Serialize, Debug, Clone)]
367#[serde(rename_all = "camelCase")]
368#[cfg_attr(feature = "integration_testing", derive(Dummy))]
369pub enum PresentationHint {
370    Normal,
371    Emphasize,
372    DeEmphasize,
373}
374
375#[derive(Deserialize, Serialize, Debug, Clone)]
376#[serde(rename_all = "camelCase")]
377#[cfg_attr(feature = "integration_testing", derive(Dummy))]
378pub struct Checksum {
379    /// The algorithm used to calculate this checksum.
380    pub algorithm: ChecksumAlgorithm,
381    /// Value of the checksum, encoded as a hexadecimal value.
382    pub checksum: String,
383}
384
385/// An ExceptionFilterOptions is used to specify an exception filter together with a condition for
386/// the setExceptionBreakpoints request.
387#[derive(Deserialize, Serialize, Debug, Default, Clone)]
388#[serde(rename_all = "camelCase")]
389#[cfg_attr(feature = "integration_testing", derive(Dummy))]
390pub struct ExceptionFilterOptions {
391    /// ID of an exception filter returned by the `exceptionBreakpointFilters`
392    /// capability.
393    pub filter_id: String,
394    /// An expression for conditional exceptions.
395    /// The exception breaks into the debugger if the result of the condition is
396    /// true.
397    #[serde(skip_serializing_if = "Option::is_none")]
398    pub condition: Option<String>,
399}
400
401/// This enumeration defines all possible conditions when a thrown exception should result in a
402/// break.
403///
404/// Specification: [`ExceptionBreakMode`](https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionBreakMode)
405#[derive(Deserialize, Serialize, Debug, Clone, Default)]
406#[serde(rename_all = "camelCase")]
407#[cfg_attr(feature = "integration_testing", derive(Dummy))]
408pub enum ExceptionBreakMode {
409    /// never breaks
410    #[default]
411    Never,
412    /// always breaks
413    Always,
414    /// breaks when exception unhandled
415    Unhandled,
416    /// breaks if the exception is not handled by user code
417    UserUnhandled,
418}
419
420/// An ExceptionPathSegment represents a segment in a path that is used to match leafs or nodes in
421/// a tree of exceptions.
422/// If a segment consists of more than one name, it matches the names provided if negate is false
423/// or missing, or it matches anything except the names provided if negate is true.
424///
425/// Specification: [`ExceptionPathSegment`](https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionPathSegment)
426#[derive(Deserialize, Serialize, Debug, Default, Clone)]
427#[serde(rename_all = "camelCase")]
428#[cfg_attr(feature = "integration_testing", derive(Dummy))]
429pub struct ExceptionPathSegment {
430    /// If false or missing this segment matches the names provided, otherwise it
431    /// matches anything except the names provided.
432    #[serde(skip_serializing_if = "Option::is_none")]
433    pub negate: Option<bool>,
434    /// Depending on the value of `negate` the names that should match or not
435    /// match.
436    pub names: Vec<String>,
437}
438
439/// An ExceptionOptions assigns configuration options to a set of exceptions.
440///
441/// Specification: [`ExceptionOptions`](https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionOptions)
442#[derive(Deserialize, Serialize, Debug, Clone)]
443#[serde(rename_all = "camelCase")]
444#[cfg_attr(feature = "integration_testing", derive(Dummy))]
445pub struct ExceptionOptions {
446    /// A path that selects a single or multiple exceptions in a tree. If `path` is
447    /// missing, the whole tree is selected.
448    /// By convention the first segment of the path is a category that is used to
449    /// group exceptions in the UI.
450    #[serde(skip_serializing_if = "Option::is_none")]
451    pub path: Option<Vec<ExceptionPathSegment>>,
452    /// Condition when a thrown exception should result in a break.
453    pub break_mode: ExceptionBreakMode,
454}
455
456/// Properties of a breakpoint passed to the setFunctionBreakpoints request.
457///
458/// Specification: [FunctionBreakpoint](https://microsoft.github.io/debug-adapter-protocol/specification#Types_FunctionBreakpoint)
459#[derive(Deserialize, Serialize, Debug, Default, Clone)]
460#[serde(rename_all = "camelCase")]
461#[cfg_attr(feature = "integration_testing", derive(Dummy))]
462pub struct FunctionBreakpoint {
463    /// The name of the function.
464    pub name: String,
465    /// An expression for conditional breakpoints.
466    /// It is only honored by a debug adapter if the corresponding capability
467    /// `supportsConditionalBreakpoints` is true.
468    #[serde(skip_serializing_if = "Option::is_none")]
469    pub condition: Option<String>,
470    /// An expression that controls how many hits of the breakpoint are ignored.
471    /// The debug adapter is expected to interpret the expression as needed.
472    /// The attribute is only honored by a debug adapter if the corresponding
473    /// capability `supportsHitConditionalBreakpoints` is true.
474    #[serde(skip_serializing_if = "Option::is_none")]
475    pub hit_condition: Option<String>,
476}
477
478#[derive(Deserialize, Serialize, Debug, Clone)]
479#[serde(rename_all = "camelCase")]
480#[cfg_attr(feature = "integration_testing", derive(Dummy))]
481pub enum BreakpointEventReason {
482    Changed,
483    New,
484    Removed,
485    #[serde(untagged)]
486    String(String),
487}
488
489#[derive(Deserialize, Serialize, Debug, Clone)]
490#[serde(rename_all = "camelCase")]
491#[cfg_attr(feature = "integration_testing", derive(Dummy))]
492pub enum InvalidatedAreas {
493    All,
494    Stacks,
495    Threads,
496    Variables,
497    #[serde(untagged)]
498    String(String),
499}
500
501#[derive(Deserialize, Serialize, Debug, Clone)]
502#[serde(rename_all = "camelCase")]
503#[cfg_attr(feature = "integration_testing", derive(Dummy))]
504pub enum LoadedSourceEventReason {
505    New,
506    Changed,
507    Removed,
508}
509
510#[derive(Deserialize, Serialize, Debug, Clone)]
511#[serde(rename_all = "camelCase")]
512#[cfg_attr(feature = "integration_testing", derive(Dummy))]
513pub enum ModuleEventReason {
514    New,
515    Changed,
516    Removed,
517}
518
519#[derive(Deserialize, Serialize, Debug, Clone)]
520#[serde(rename_all = "camelCase")]
521#[cfg_attr(feature = "integration_testing", derive(Dummy))]
522pub struct Module {
523    /// Unique identifier for the module.
524    pub id: ModuleId,
525    /// A name of the module.
526    pub name: String,
527    /// Logical full path to the module. The exact definition is implementation
528    /// defined, but usually this would be a full path to the on-disk file for the
529    /// module.
530    #[serde(skip_serializing_if = "Option::is_none")]
531    pub path: Option<String>,
532    /// True if the module is optimized.
533    #[serde(skip_serializing_if = "Option::is_none")]
534    pub is_optimized: Option<bool>,
535    /// True if the module is considered 'user code' by a debugger that supports
536    /// 'Just My Code'.
537    #[serde(skip_serializing_if = "Option::is_none")]
538    pub is_user_code: Option<bool>,
539    /// Version of Module.
540    #[serde(skip_serializing_if = "Option::is_none")]
541    pub version: Option<String>,
542    /// User-understandable description of if symbols were found for the module
543    /// (ex: 'Symbols Loaded', 'Symbols not found', etc.)
544    #[serde(skip_serializing_if = "Option::is_none")]
545    pub symbol_status: Option<String>,
546    /// Logical full path to the symbol file. The exact definition is
547    /// implementation defined.
548    #[serde(skip_serializing_if = "Option::is_none")]
549    pub symbol_file_path: Option<String>,
550    /// Module created or modified, encoded as a RFC 3339 timestamp.
551    #[serde(skip_serializing_if = "Option::is_none")]
552    pub date_time_stamp: Option<String>,
553    /// Address range covered by this module.
554    #[serde(skip_serializing_if = "Option::is_none")]
555    pub address_range: Option<String>,
556}
557
558#[derive(Deserialize, Serialize, Debug, Clone)]
559#[serde(rename_all = "camelCase")]
560#[cfg_attr(feature = "integration_testing", derive(Dummy))]
561pub enum ModuleId {
562    Number,
563    #[serde(untagged)]
564    String(String),
565}
566
567#[derive(Deserialize, Serialize, Debug, Clone)]
568#[serde(rename_all = "camelCase")]
569#[cfg_attr(feature = "integration_testing", derive(Dummy))]
570pub enum OutputEventCategory {
571    Console,
572    Important,
573    Stdout,
574    Stderr,
575    Telemetry,
576    #[serde(untagged)]
577    String(String),
578}
579
580#[derive(Deserialize, Serialize, Debug, Clone)]
581#[serde(rename_all = "camelCase")]
582#[cfg_attr(feature = "integration_testing", derive(Dummy))]
583pub enum OutputEventGroup {
584    Start,
585    StartCollapsed,
586    End,
587}
588
589#[derive(Deserialize, Serialize, Debug, Clone)]
590#[serde(rename_all = "camelCase")]
591#[cfg_attr(feature = "integration_testing", derive(Dummy))]
592pub enum ProcessEventStartMethod {
593    Launch,
594    Attach,
595    AttachForSuspendedLaunch,
596}
597
598#[derive(Deserialize, Serialize, Debug, Clone)]
599#[serde(rename_all = "camelCase")]
600#[cfg_attr(feature = "integration_testing", derive(Dummy))]
601pub enum StoppedEventReason {
602    Step,
603    Breakpoint,
604    Exception,
605    Pause,
606    Entry,
607    Goto,
608    Function,
609    Data,
610    Instruction,
611    #[serde(untagged)]
612    String(String),
613}
614
615#[derive(Deserialize, Serialize, Debug, Clone)]
616#[serde(rename_all = "camelCase")]
617#[cfg_attr(feature = "integration_testing", derive(Dummy))]
618pub enum ThreadEventReason {
619    Started,
620    Exited,
621    #[serde(untagged)]
622    String(String),
623}
624
625#[derive(Deserialize, Serialize, Debug, Default, Clone)]
626#[serde(rename_all = "camelCase")]
627#[cfg_attr(feature = "integration_testing", derive(Dummy))]
628pub struct ValueFormat {
629    /// Display the value in hex.
630    #[serde(skip_serializing_if = "Option::is_none")]
631    pub hex: Option<bool>,
632}
633
634#[derive(Deserialize, Serialize, Debug, Default, Clone)]
635#[serde(rename_all = "camelCase")]
636pub struct StackFrameFormat {
637    /// Displays parameters for the stack frame.
638    #[serde(skip_serializing_if = "Option::is_none")]
639    pub parameters: Option<bool>,
640    /// Displays the types of parameters for the stack frame.
641    #[serde(skip_serializing_if = "Option::is_none")]
642    pub parameter_types: Option<bool>,
643    /// Displays the names of parameters for the stack frame.
644    #[serde(skip_serializing_if = "Option::is_none")]
645    pub parameter_names: Option<bool>,
646    /// Displays the values of parameters for the stack frame.
647    #[serde(skip_serializing_if = "Option::is_none")]
648    pub parameter_values: Option<bool>,
649    /// Displays the line i64 of the stack frame.
650    #[serde(skip_serializing_if = "Option::is_none")]
651    pub line: Option<bool>,
652    /// Displays the module of the stack frame.
653    #[serde(skip_serializing_if = "Option::is_none")]
654    pub module: Option<bool>,
655    /// Includes all stack frames, including those the debug adapter might
656    /// otherwise hide.
657    #[serde(skip_serializing_if = "Option::is_none")]
658    pub include_all: Option<bool>,
659}
660
661#[derive(Deserialize, Serialize, Debug, Clone)]
662#[serde(rename_all = "camelCase")]
663#[cfg_attr(feature = "integration_testing", derive(Dummy))]
664pub enum EvaluateArgumentsContext {
665    Variables,
666    Watch,
667    Repl,
668    Hover,
669    Clipboard,
670    #[serde(untagged)]
671    String(String),
672}
673
674#[derive(Deserialize, Serialize, Debug, Clone)]
675#[serde(rename_all = "camelCase")]
676#[cfg_attr(feature = "integration_testing", derive(Dummy))]
677pub enum SteppingGranularity {
678    Statement,
679    Line,
680    Instruction,
681}
682
683#[derive(Deserialize, Serialize, Debug, Clone)]
684#[serde(rename_all = "camelCase")]
685#[cfg_attr(feature = "integration_testing", derive(Dummy))]
686pub enum DataBreakpointAccessType {
687    Read,
688    Write,
689    ReadWrite,
690}
691
692#[derive(Deserialize, Serialize, Debug, Default, Clone)]
693#[serde(rename_all = "camelCase")]
694#[cfg_attr(feature = "integration_testing", derive(Dummy))]
695pub struct DataBreakpoint {
696    /// An id representing the data. This id is returned from the
697    /// `dataBreakpointInfo` request.
698    pub data_id: String,
699    /// The access type of the data.
700    #[serde(skip_serializing_if = "Option::is_none")]
701    pub access_type: Option<DataBreakpointAccessType>,
702    /// An expression for conditional breakpoints.
703    #[serde(skip_serializing_if = "Option::is_none")]
704    pub condition: Option<String>,
705    /// An expression that controls how many hits of the breakpoint are ignored.
706    /// The debug adapter is expected to interpret the expression as needed.
707    #[serde(skip_serializing_if = "Option::is_none")]
708    pub hit_condition: Option<String>,
709}
710
711/// Properties of a breakpoint passed to the setInstructionBreakpoints request
712///
713/// Specfication: [InstructionBreakpoint](https://microsoft.github.io/debug-adapter-protocol/specification#Types_InstructionBreakpoint)
714#[derive(Deserialize, Serialize, Debug, Default, Clone)]
715#[serde(rename_all = "camelCase")]
716#[cfg_attr(feature = "integration_testing", derive(Dummy))]
717pub struct InstructionBreakpoint {
718    /// The instruction reference of the breakpoint.
719    /// This should be a memory or instruction pointer reference from an
720    /// `EvaluateResponse`, `Variable`, `StackFrame`, `GotoTarget`, or
721    /// `Breakpoint`.
722    pub instruction_reference: String,
723    /// The offset from the instruction reference.
724    /// This can be negative.
725    #[serde(skip_serializing_if = "Option::is_none")]
726    pub offset: Option<i64>,
727    /// An expression for conditional breakpoints.
728    /// It is only honored by a debug adapter if the corresponding capability
729    /// `supportsConditionalBreakpoints` is true.
730    #[serde(skip_serializing_if = "Option::is_none")]
731    pub condition: Option<String>,
732    /// An expression that controls how many hits of the breakpoint are ignored.
733    /// The debug adapter is expected to interpret the expression as needed.
734    /// The attribute is only honored by a debug adapter if the corresponding
735    /// capability `supportsHitConditionalBreakpoints` is true.
736    #[serde(skip_serializing_if = "Option::is_none")]
737    pub hit_condition: Option<String>,
738}
739
740#[derive(Deserialize, Serialize, Debug, Clone)]
741#[serde(rename_all = "camelCase")]
742#[cfg_attr(feature = "integration_testing", derive(Dummy))]
743pub enum VariablesArgumentsFilter {
744    Indexed,
745    Named,
746}
747
748/// Properties of a breakpoint location returned from the breakpointLocations request.
749/// Specfication: [BreakpointLocation](https://microsoft.github.io/debug-adapter-protocol/specification#Types_BreakpointLocation)
750#[derive(Deserialize, Serialize, Debug, Default, Clone)]
751#[serde(rename_all = "camelCase")]
752#[cfg_attr(feature = "integration_testing", derive(Dummy))]
753pub struct BreakpointLocation {
754    /// Start line of breakpoint location.
755    pub line: i64,
756    /// The start position of a breakpoint location. Position is measured in UTF-16
757    /// code units and the client capability `columnsStartAt1` determines whether
758    /// it is 0- or 1-based.
759    #[serde(skip_serializing_if = "Option::is_none")]
760    pub column: Option<i64>,
761    /// The end line of breakpoint location if the location covers a range.
762    #[serde(skip_serializing_if = "Option::is_none")]
763    pub end_line: Option<i64>,
764    /// The end position of a breakpoint location (if the location covers a range).
765    /// Position is measured in UTF-16 code units and the client capability
766    /// `columnsStartAt1` determines whether it is 0- or 1-based.
767    #[serde(skip_serializing_if = "Option::is_none")]
768    pub end_column: Option<i64>,
769}
770
771/// Some predefined types for the CompletionItem. Please note that not all clients have specific
772/// icons for all of them
773///
774/// Specification: [CompletionItemType](https://microsoft.github.io/debug-adapter-protocol/specification#Types_CompletionItemType)
775#[derive(Deserialize, Serialize, Debug, Clone)]
776#[serde(rename_all = "camelCase")]
777#[cfg_attr(feature = "integration_testing", derive(Dummy))]
778pub enum CompletionItemType {
779    Method,
780    Function,
781    Constructor,
782    Field,
783    Variable,
784    Class,
785    Interface,
786    Module,
787    Property,
788    Unit,
789    Value,
790    Enum,
791    Keyword,
792    Snippet,
793    Text,
794    Color,
795    File,
796    Reference,
797    CustomColor,
798}
799
800/// `CompletionItems` are the suggestions returned from the `completions` request.
801///
802/// Specification: [CompletionItem](https://microsoft.github.io/debug-adapter-protocol/specification#Types_CompletionItem)
803#[derive(Deserialize, Serialize, Debug, Default, Clone)]
804#[serde(rename_all = "camelCase")]
805#[cfg_attr(feature = "integration_testing", derive(Dummy))]
806pub struct CompletionItem {
807    /// The label of this completion item. By default this is also the text that is
808    /// inserted when selecting this completion.
809    pub label: String,
810    /// If text is returned and not an empty String, then it is inserted instead of
811    /// the label.
812    #[serde(skip_serializing_if = "Option::is_none")]
813    pub text: Option<String>,
814    /// A String that should be used when comparing this item with other items. If
815    /// not returned or an empty String, the `label` is used instead.
816    #[serde(skip_serializing_if = "Option::is_none")]
817    pub sort_text: Option<String>,
818    /// A human-readable String with additional information about this item, like
819    /// type or symbol information.
820    #[serde(skip_serializing_if = "Option::is_none")]
821    pub detail: Option<String>,
822    /// The item's type. Typically the client uses this information to render the
823    /// item in the UI with an icon.
824    #[serde(rename = "type")]
825    #[serde(skip_serializing_if = "Option::is_none")]
826    pub type_field: Option<CompletionItemType>,
827    /// Start position (within the `text` attribute of the `completions` request)
828    /// where the completion text is added. The position is measured in UTF-16 code
829    /// units and the client capability `columnsStartAt1` determines whether it is
830    /// 0- or 1-based. If the start position is omitted the text is added at the
831    /// location specified by the `column` attribute of the `completions` request.
832    #[serde(skip_serializing_if = "Option::is_none")]
833    pub start: Option<i64>,
834    /// Length determines how many characters are overwritten by the completion
835    /// text and it is measured in UTF-16 code units. If missing the value 0 is
836    /// assumed which results in the completion text being inserted.
837    #[serde(skip_serializing_if = "Option::is_none")]
838    pub length: Option<i64>,
839    /// Determines the start of the new selection after the text has been inserted
840    /// (or replaced). `selectionStart` is measured in UTF-16 code units and must
841    /// be in the range 0 and length of the completion text. If omitted the
842    /// selection starts at the end of the completion text.
843    #[serde(skip_serializing_if = "Option::is_none")]
844    pub selection_start: Option<i64>,
845    /// Determines the length of the new selection after the text has been inserted
846    /// (or replaced) and it is measured in UTF-16 code units. The selection can
847    /// not extend beyond the bounds of the completion text. If omitted the length
848    /// is assumed to be 0.
849    #[serde(skip_serializing_if = "Option::is_none")]
850    pub selection_length: Option<i64>,
851}
852
853/// Represents a single disassembled instruction.
854///
855/// Specification: [DisassembledInstruction](https://microsoft.github.io/debug-adapter-protocol/specification#Types_DisassembledInstruction)
856#[derive(Deserialize, Serialize, Debug, Default, Clone)]
857#[serde(rename_all = "camelCase")]
858#[cfg_attr(feature = "integration_testing", derive(Dummy))]
859pub struct DisassembledInstruction {
860    /// The address of the instruction. Treated as a hex value if prefixed with
861    /// `0x`, or as a decimal value otherwise.
862    pub address: String,
863    /// Raw bytes representing the instruction and its operands, in an
864    /// implementation-defined format.
865    #[serde(skip_serializing_if = "Option::is_none")]
866    pub instruction_bytes: Option<String>,
867    /// Text representing the instruction and its operands, in an
868    /// implementation-defined format.
869    pub instruction: String,
870    /// Name of the symbol that corresponds with the location of this instruction,
871    /// if any.
872    #[serde(skip_serializing_if = "Option::is_none")]
873    pub symbol: Option<String>,
874    /// Source location that corresponds to this instruction, if any.
875    /// Should always be set (if available) on the first instruction returned,
876    /// but can be omitted afterwards if this instruction maps to the same source
877    /// file as the previous instruction.
878    #[serde(skip_serializing_if = "Option::is_none")]
879    pub location: Option<Source>,
880    /// The line within the source location that corresponds to this instruction,
881    /// if any.
882    #[serde(skip_serializing_if = "Option::is_none")]
883    pub line: Option<i64>,
884    /// The column within the line that corresponds to this instruction, if any.
885    #[serde(skip_serializing_if = "Option::is_none")]
886    pub column: Option<i64>,
887    /// The end line of the range that corresponds to this instruction, if any.
888    #[serde(skip_serializing_if = "Option::is_none")]
889    pub end_line: Option<i64>,
890    /// The end column of the range that corresponds to this instruction, if any.
891    #[serde(skip_serializing_if = "Option::is_none")]
892    pub end_column: Option<i64>,
893}
894
895#[derive(Deserialize, Serialize, Debug, Clone)]
896#[serde(rename_all = "camelCase")]
897#[cfg_attr(feature = "integration_testing", derive(Dummy))]
898pub enum VariablePresentationHintKind {
899    /// Indicates that the object is a property.
900    Property,
901    /// Indicates that the object is a method.
902    Method,
903    /// Indicates that the object is a class.
904    Class,
905    /// Indicates that the object is data.
906    Data,
907    /// Indicates that the object is an event.
908    Event,
909    /// Indicates that the object is a base class.
910    BaseClass,
911    /// Indicates that the object is an inner class.
912    InnerClass,
913    /// Indicates that the object is an interface.
914    Interface,
915    /// Indicates that the object is the most derived class.
916    MostDerivedClass,
917    /// Indicates that the object is virtual, that means it is a
918    /// synthetic object introduced by the adapter for rendering purposes, e.g. an
919    /// index range for large arrays.
920    Virtual,
921    /// Deprecated: Indicates that a data breakpoint is
922    /// registered for the object. The `hasDataBreakpoint` attribute should
923    /// generally be used instead.
924    DataBreakpoint,
925    #[serde(untagged)]
926    String(String),
927}
928
929/// Set of attributes represented as an array of Strings. Before introducing
930/// additional values, try to use the listed values.
931#[derive(Deserialize, Serialize, Debug, Clone)]
932#[serde(rename_all = "camelCase")]
933#[cfg_attr(feature = "integration_testing", derive(Dummy))]
934pub enum VariablePresentationHintAttributes {
935    /// Indicates that the object is static.
936    Static,
937    /// Indicates that the object is a constant.
938    Constant,
939    /// Indicates that the object is read only.
940    ReadOnly,
941    /// Indicates that the object is a raw String.
942    RawString,
943    /// Indicates that the object can have an Object ID created for it.
944    HasObjectId,
945    /// Indicates that the object has an Object ID associated with it.
946    CanHaveObjectId,
947    /// Indicates that the evaluation had side effects.
948    HasSideEffects,
949    /// Indicates that the object has its value tracked by a data breakpoint.
950    HasDataBreakpoint,
951    #[serde(untagged)]
952    String(String),
953}
954
955#[derive(Deserialize, Serialize, Debug, Clone)]
956#[serde(rename_all = "camelCase")]
957#[cfg_attr(feature = "integration_testing", derive(Dummy))]
958pub enum VariablePresentationHintVisibility {
959    Public,
960    Private,
961    Protected,
962    Internal,
963    Final,
964    #[serde(untagged)]
965    String(String),
966}
967
968#[derive(Deserialize, Serialize, Debug, Default, Clone)]
969#[cfg_attr(feature = "integration_testing", derive(Dummy))]
970#[serde(rename_all = "camelCase")]
971pub struct VariablePresentationHint {
972    /// The kind of variable. Before introducing additional values, try to use the
973    /// listed values.
974    /// Values:
975    /// 'property': Indicates that the object is a property.
976    /// 'method': Indicates that the object is a method.
977    /// 'class': Indicates that the object is a class.
978    /// 'data': Indicates that the object is data.
979    /// 'event': Indicates that the object is an event.
980    /// 'baseClass': Indicates that the object is a base class.
981    /// 'innerClass': Indicates that the object is an inner class.
982    /// 'interface': Indicates that the object is an interface.
983    /// 'mostDerivedClass': Indicates that the object is the most derived class.
984    /// 'virtual': Indicates that the object is virtual, that means it is a
985    /// synthetic object introduced by the adapter for rendering purposes, e.g. an
986    /// index range for large arrays.
987    /// 'dataBreakpoint': Deprecated: Indicates that a data breakpoint is
988    /// registered for the object. The `hasDataBreakpoint` attribute should
989    /// generally be used instead.
990    /// etc.
991    #[serde(skip_serializing_if = "Option::is_none")]
992    pub kind: Option<VariablePresentationHintKind>,
993    /// Set of attributes represented as an array of Strings. Before introducing
994    /// additional values, try to use the listed values.
995    /// Values:
996    /// 'static': Indicates that the object is static.
997    /// 'constant': Indicates that the object is a constant.
998    /// 'readOnly': Indicates that the object is read only.
999    /// 'rawString': Indicates that the object is a raw String.
1000    /// 'hasObjectId': Indicates that the object can have an Object ID created for
1001    /// it.
1002    /// 'canHaveObjectId': Indicates that the object has an Object ID associated
1003    /// with it.
1004    /// 'hasSideEffects': Indicates that the evaluation had side effects.
1005    /// 'hasDataBreakpoint': Indicates that the object has its value tracked by a
1006    /// data breakpoint.
1007    /// etc.
1008    #[serde(skip_serializing_if = "Option::is_none")]
1009    pub attributes: Option<Vec<VariablePresentationHintAttributes>>,
1010    /// Visibility of variable. Before introducing additional values, try to use
1011    /// the listed values.
1012    /// Values: 'public', 'private', 'protected', 'internal', 'final', etc.
1013    #[serde(skip_serializing_if = "Option::is_none")]
1014    pub visibility: Option<VariablePresentationHintVisibility>,
1015    /// If true, clients can present the variable with a UI that supports a
1016    /// specific gesture to trigger its evaluation.
1017    /// This mechanism can be used for properties that require executing code when
1018    /// retrieving their value and where the code execution can be expensive and/or
1019    /// produce side-effects. A typical example are properties based on a getter
1020    /// function.
1021    /// Please note that in addition to the `lazy` flag, the variable's
1022    /// `variablesReference` is expected to refer to a variable that will provide
1023    /// the value through another `variable` request.
1024    #[serde(skip_serializing_if = "Option::is_none")]
1025    pub lazy: Option<bool>,
1026}
1027
1028/// Detailed information about an exception that has occurred.
1029///
1030/// Specification: [ExceptionDetails](https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionDetails)
1031#[derive(Deserialize, Serialize, Debug, Default, Clone)]
1032#[serde(rename_all = "camelCase")]
1033#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1034pub struct ExceptionDetails {
1035    /// Message contained in the exception.
1036    #[serde(skip_serializing_if = "Option::is_none")]
1037    pub message: Option<String>,
1038    /// Short type name of the exception object.
1039    #[serde(skip_serializing_if = "Option::is_none")]
1040    pub type_name: Option<String>,
1041    /// Fully-qualified type name of the exception object.
1042    #[serde(skip_serializing_if = "Option::is_none")]
1043    pub full_type_name: Option<String>,
1044    /// An expression that can be evaluated in the current scope to obtain the
1045    /// exception object.
1046    #[serde(skip_serializing_if = "Option::is_none")]
1047    pub evaluate_name: Option<String>,
1048    /// Stack trace at the time the exception was thrown.
1049    #[serde(skip_serializing_if = "Option::is_none")]
1050    pub stack_trace: Option<String>,
1051    /// Details of the exception contained by this exception, if any.
1052    #[serde(skip_serializing_if = "Option::is_none")]
1053    pub inner_exception: Option<Vec<ExceptionDetails>>,
1054}
1055
1056/// A `GotoTarget` describes a code location that can be used as a target in the
1057/// goto request.
1058/// The possible goto targets can be determined via the gotoTargets request.
1059///
1060/// Specification: [GotoTarget](https://microsoft.github.io/debug-adapter-protocol/specification#Types_GotoTarget)
1061#[derive(Deserialize, Serialize, Debug, Default, Clone)]
1062#[serde(rename_all = "camelCase")]
1063#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1064pub struct GotoTarget {
1065    /// Unique identifier for a goto target. This is used in the `goto` request.
1066    pub id: i64,
1067    /// The name of the goto target (shown in the UI).
1068    pub label: String,
1069    /// The line of the goto target.
1070    pub line: i64,
1071    /// The column of the goto target.
1072    #[serde(skip_serializing_if = "Option::is_none")]
1073    pub column: Option<i64>,
1074    /// The end line of the range covered by the goto target.
1075    #[serde(skip_serializing_if = "Option::is_none")]
1076    pub end_line: Option<i64>,
1077    /// The end column of the range covered by the goto target.
1078    #[serde(skip_serializing_if = "Option::is_none")]
1079    pub end_column: Option<i64>,
1080    /// A memory reference for the instruction pointer value represented by this
1081    /// target.
1082    #[serde(skip_serializing_if = "Option::is_none")]
1083    pub instruction_pointer_reference: Option<String>,
1084}
1085
1086/// A hint for how to present this scope in the UI. If this attribute is
1087/// missing, the scope is shown with a generic UI.
1088///
1089/// Specification: [Scope](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope)
1090#[derive(Deserialize, Serialize, Debug, Clone)]
1091#[serde(rename_all = "camelCase")]
1092#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1093pub enum ScopePresentationhint {
1094    /// Scope contains method arguments.
1095    Arguments,
1096    /// Scope contains local variables.
1097    Locals,
1098    /// Scope contains registers. Only a single `registers` scope
1099    /// should be returned from a `scopes` request.
1100    Registers,
1101    #[serde(untagged)]
1102    String(String),
1103}
1104
1105/// A Scope is a named container for variables. Optionally a scope can map to a source or a range
1106/// within a source.
1107///
1108/// Specification: [Scope](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope)
1109#[derive(Deserialize, Serialize, Debug, Default, Clone)]
1110#[serde(rename_all = "camelCase")]
1111#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1112pub struct Scope {
1113    /// Name of the scope such as 'Arguments', 'Locals', or 'Registers'. This
1114    /// String is shown in the UI as is and can be translated.
1115    pub name: String,
1116    /// A hint for how to present this scope in the UI. If this attribute is
1117    /// missing, the scope is shown with a generic UI.
1118    /// Values:
1119    /// 'arguments': Scope contains method arguments.
1120    /// 'locals': Scope contains local variables.
1121    /// 'registers': Scope contains registers. Only a single `registers` scope
1122    /// should be returned from a `scopes` request.
1123    /// etc.
1124    #[serde(skip_serializing_if = "Option::is_none")]
1125    pub presentation_hint: Option<ScopePresentationhint>,
1126    /// The variables of this scope can be retrieved by passing the value of
1127    /// `variablesReference` to the `variables` request as long as execution
1128    /// remains suspended. See [Lifetime of Object References](https://microsoft.github.io/debug-adapter-protocol/overview#lifetime-of-objects-references)
1129    /// in the Overview section of the specification for details.
1130    pub variables_reference: i64,
1131    /// The i64 of named variables in this scope.
1132    /// The client can use this information to present the variables in a paged UI
1133    /// and fetch them in chunks.
1134    #[serde(skip_serializing_if = "Option::is_none")]
1135    pub named_variables: Option<i64>,
1136    /// The i64 of indexed variables in this scope.
1137    /// The client can use this information to present the variables in a paged UI
1138    /// and fetch them in chunks.
1139    #[serde(skip_serializing_if = "Option::is_none")]
1140    pub indexed_variables: Option<i64>,
1141    /// If true, the i64 of variables in this scope is large or expensive to
1142    /// retrieve.
1143    pub expensive: bool,
1144    /// The source for this scope.
1145    #[serde(skip_serializing_if = "Option::is_none")]
1146    pub source: Option<Source>,
1147    /// The start line of the range covered by this scope.
1148    #[serde(skip_serializing_if = "Option::is_none")]
1149    pub line: Option<i64>,
1150    /// Start position of the range covered by the scope. It is measured in UTF-16
1151    /// code units and the client capability `columnsStartAt1` determines whether
1152    /// it is 0- or 1-based.
1153    #[serde(skip_serializing_if = "Option::is_none")]
1154    pub column: Option<i64>,
1155    /// The end line of the range covered by this scope.
1156    #[serde(skip_serializing_if = "Option::is_none")]
1157    pub end_line: Option<i64>,
1158    /// End position of the range covered by the scope. It is measured in UTF-16
1159    /// code units and the client capability `columnsStartAt1` determines whether
1160    /// it is 0- or 1-based.
1161    #[serde(skip_serializing_if = "Option::is_none")]
1162    pub end_column: Option<i64>,
1163}
1164
1165#[derive(Deserialize, Serialize, Debug, Clone)]
1166#[serde(untagged)]
1167#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1168pub enum StackFrameModuleid {
1169    Number(i64),
1170    String(String),
1171}
1172
1173#[derive(Deserialize, Serialize, Debug, Clone)]
1174#[serde(rename_all = "camelCase")]
1175#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1176pub enum StackFramePresentationhint {
1177    Normal,
1178    Label,
1179    Subtle,
1180}
1181
1182/// A Stackframe contains the source location.
1183///
1184/// Specification: [StackFrame](https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame)
1185#[derive(Deserialize, Serialize, Debug, Default, Clone)]
1186#[serde(rename_all = "camelCase")]
1187#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1188pub struct StackFrame {
1189    /// An identifier for the stack frame. It must be unique across all threads.
1190    /// This id can be used to retrieve the scopes of the frame with the `scopes`
1191    /// request or to restart the execution of a stackframe.
1192    pub id: i64,
1193    /// The name of the stack frame, typically a method name.
1194    pub name: Arc<str>,
1195    /// The source of the frame.
1196    #[serde(skip_serializing_if = "Option::is_none")]
1197    pub source: Option<Source>,
1198    /// The line within the source of the frame. If the source attribute is missing
1199    /// or doesn't exist, `line` is 0 and should be ignored by the client.
1200    pub line: i64,
1201    /// Start position of the range covered by the stack frame. It is measured in
1202    /// UTF-16 code units and the client capability `columnsStartAt1` determines
1203    /// whether it is 0- or 1-based. If attribute `source` is missing or doesn't
1204    /// exist, `column` is 0 and should be ignored by the client.
1205    pub column: i64,
1206    /// The end line of the range covered by the stack frame.
1207    #[serde(skip_serializing_if = "Option::is_none")]
1208    pub end_line: Option<i64>,
1209    /// End position of the range covered by the stack frame. It is measured in
1210    /// UTF-16 code units and the client capability `columnsStartAt1` determines
1211    /// whether it is 0- or 1-based.
1212    #[serde(skip_serializing_if = "Option::is_none")]
1213    pub end_column: Option<i64>,
1214    /// Indicates whether this frame can be restarted with the `restart` request.
1215    /// Clients should only use this if the debug adapter supports the `restart`
1216    /// request and the corresponding capability `supportsRestartRequest` is true.
1217    #[serde(skip_serializing_if = "Option::is_none")]
1218    pub can_restart: Option<bool>,
1219    /// A memory reference for the current instruction pointer in this frame.
1220    #[serde(skip_serializing_if = "Option::is_none")]
1221    pub instruction_pointer_reference: Option<String>,
1222    /// The module associated with this frame, if any.
1223    #[serde(skip_serializing_if = "Option::is_none")]
1224    pub module_id: Option<StackFrameModuleid>,
1225    /// A hint for how to present this frame in the UI.
1226    /// A value of `label` can be used to indicate that the frame is an artificial
1227    /// frame that is used as a visual label or separator. A value of `subtle` can
1228    /// be used to change the appearance of a frame in a 'subtle' way.
1229    /// Values: 'normal', 'label', 'subtle'
1230    #[serde(skip_serializing_if = "Option::is_none")]
1231    pub presentation_hint: Option<StackFramePresentationhint>,
1232}
1233
1234/// A thread.
1235///
1236/// Specification: [Thread](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Thread)
1237#[derive(Deserialize, Serialize, Debug, Default, Clone)]
1238#[serde(rename_all = "camelCase")]
1239#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1240pub struct Thread {
1241    /// Unique identifier for the thread.
1242    pub id: i64,
1243    /// The name of the thread.
1244    pub name: String,
1245}
1246
1247/// A Variable is a name/value pair.
1248///
1249/// The `type` attribute is shown if space permits or when hovering over the variable’s name.
1250///
1251/// The `kind` attribute is used to render additional properties of the variable, e.g. different
1252/// icons can be used to indicate that a variable is public or private.
1253///
1254/// If the value is structured (has children), a handle is provided to retrieve the children with
1255/// the `variables` request.
1256///
1257/// If the number of named or indexed children is large, the numbers should be returned via the
1258/// `namedVariables` and `indexedVariables` attributes.
1259///
1260/// The client can use this information to present the children in a paged UI and fetch them in
1261/// chunks.
1262#[derive(Deserialize, Serialize, Debug, Default, Clone)]
1263#[serde(rename_all = "camelCase")]
1264#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1265pub struct Variable {
1266    /// The variable's name.
1267    pub name: String,
1268    /// The variable's value.
1269    /// This can be a multi-line text, e.g. for a function the body of a function.
1270    /// For structured variables (which do not have a simple value), it is
1271    /// recommended to provide a one-line representation of the structured object.
1272    /// This helps to identify the structured object in the collapsed state when
1273    /// its children are not yet visible.
1274    /// An empty String can be used if no value should be shown in the UI.
1275    pub value: String,
1276    /// The type of the variable's value. Typically shown in the UI when hovering
1277    /// over the value.
1278    /// This attribute should only be returned by a debug adapter if the
1279    /// corresponding capability `supportsVariableType` is true.
1280    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
1281    pub type_field: Option<String>,
1282    /// Properties of a variable that can be used to determine how to render the
1283    /// variable in the UI.
1284    #[serde(skip_serializing_if = "Option::is_none")]
1285    pub presentation_hint: Option<VariablePresentationHint>,
1286    /// The evaluatable name of this variable which can be passed to the `evaluate`
1287    /// request to fetch the variable's value.
1288    #[serde(skip_serializing_if = "Option::is_none")]
1289    pub evaluate_name: Option<String>,
1290    /// If `variablesReference` is > 0, the variable is structured and its children
1291    /// can be retrieved by passing `variablesReference` to the `variables` request
1292    /// as long as execution remains suspended. See [Lifetime of Object References](https://microsoft.github.io/debug-adapter-protocol/overview#lifetime-of-objects-references)
1293    /// in the Overview section of the specification for details.
1294    pub variables_reference: i64,
1295    /// The i64 of named child variables.
1296    /// The client can use this information to present the children in a paged UI
1297    /// and fetch them in chunks.
1298    #[serde(skip_serializing_if = "Option::is_none")]
1299    pub named_variables: Option<i64>,
1300    /// The i64 of indexed child variables.
1301    /// The client can use this information to present the children in a paged UI
1302    /// and fetch them in chunks.
1303    #[serde(skip_serializing_if = "Option::is_none")]
1304    pub indexed_variables: Option<i64>,
1305    /// The memory reference for the variable if the variable represents executable
1306    /// code, such as a function pointer.
1307    /// This attribute is only required if the corresponding capability
1308    /// `supportsMemoryReferences` is true.
1309    #[serde(skip_serializing_if = "Option::is_none")]
1310    pub memory_reference: Option<String>,
1311}
1312
1313#[derive(Deserialize, Serialize, Debug, Clone)]
1314#[serde(rename_all = "camelCase")]
1315#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1316pub enum RunInTerminalRequestArgumentsKind {
1317    Integrated,
1318    External,
1319}
1320
1321#[derive(Deserialize, Serialize, Debug, Clone)]
1322#[serde(rename_all = "camelCase")]
1323#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1324pub enum StartDebuggingRequestKind {
1325    Launch,
1326    Attach,
1327}
1328
1329/// A structured message object. Used to return errors from requests.
1330///
1331/// Specification: [Message](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Message)
1332#[derive(Serialize, Debug, Default, Clone)]
1333#[serde(rename_all = "camelCase")]
1334#[cfg_attr(feature = "integration_testing", derive(Dummy))]
1335#[cfg_attr(feature = "client", derive(Deserialize))]
1336pub struct Message {
1337    /// Unique (within a debug adapter implementation) identifier for the message.
1338    /// The purpose of these error IDs is to help extension authors that have the
1339    /// requirement that every user visible error message needs a corresponding
1340    /// error i64, so that users or customer support can find information about
1341    /// the specific error more easily.
1342    pub id: i64,
1343    /// A format String for the message. Embedded variables have the form `{name}`.
1344    /// If variable name starts with an underscore character, the variable does not
1345    /// contain user data (PII) and can be safely used for telemetry purposes.
1346    pub format: String,
1347    /// An object used as a dictionary for looking up the variables in the format string.
1348    pub variables: HashMap<String, String>,
1349    /// An object used as a dictionary for looking up the variables in the format
1350    /// String.
1351    /// If true send to telemetry.
1352    pub send_telemetry: Option<bool>,
1353    /// If true show user.
1354    pub show_user: Option<bool>,
1355    /// A url where additional information about this message can be found.
1356    pub url: Option<String>,
1357    /// A label that is presented to the user as the UI for opening the url.
1358    pub url_label: Option<String>,
1359}
1360
1361#[cfg(test)]
1362mod tests {
1363    use super::*;
1364
1365    #[allow(unused)]
1366    #[test]
1367    fn test_checksum_algorithm_serde() {
1368        let sha = ChecksumAlgorithm::SHA256;
1369        let sha_ser = serde_json::to_value(sha).unwrap();
1370        assert_eq!("SHA256", sha_ser);
1371        let sha_deser: ChecksumAlgorithm = serde_json::from_value(sha_ser).unwrap();
1372        assert!(matches!(ChecksumAlgorithm::SHA256, sha_deser));
1373
1374        let ts = ChecksumAlgorithm::Timestamp;
1375        let ts_ser = serde_json::to_value(&ts).unwrap();
1376        assert_eq!("timestamp", ts_ser);
1377        #[allow(unused)]
1378        let ts_deser: ChecksumAlgorithm = serde_json::from_value(ts_ser).unwrap();
1379        assert!(matches!(ChecksumAlgorithm::Timestamp, ts_deser));
1380    }
1381
1382    #[allow(unused)]
1383    #[test]
1384    fn test_invalidated_areas_serde() {
1385        let str = "string".to_string();
1386        let untagged = InvalidatedAreas::String(str.clone());
1387        let untagged_ser = serde_json::to_value(untagged).unwrap();
1388        assert_eq!(str, untagged_ser);
1389        let untagged_deser: InvalidatedAreas = serde_json::from_value(untagged_ser).unwrap();
1390        assert!(matches!(InvalidatedAreas::String(str), untagged_deser));
1391    }
1392}