debug_adapter_protocol/
events.rs

1use crate::{
2    types::{Breakpoint, Capabilities, InvalidatedAreas, Module, Source},
3    utils::eq_default,
4    ProtocolMessageContent,
5};
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8use typed_builder::TypedBuilder;
9
10/// A debug adapter initiated event.
11#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
12#[serde(rename_all = "camelCase", tag = "event", content = "body")]
13pub enum Event {
14    /// The event indicates that some information about a breakpoint has changed.
15    Breakpoint(BreakpointEventBody),
16
17    /// The event indicates that one or more capabilities have changed.
18    ///
19    /// Since the capabilities are dependent on the frontend and its UI, it might not be possible to change that at random times (or too late).
20    ///
21    /// Consequently this event has a hint characteristic: a frontend can only be expected to make a 'best effort' in honouring individual capabilities but there are no guarantees.
22    ///
23    /// Only changed capabilities need to be included, all other capabilities keep their values.
24    Capabilities(CapabilitiesEventBody),
25
26    /// The event indicates that the execution of the debuggee has continued.
27    ///
28    /// Please note: a debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. 'launch' or 'continue'.
29    ///
30    /// It is only necessary to send a 'continued' event if there was no previous request that implied this.
31    Continued(ContinuedEventBody),
32
33    /// The event indicates that the debuggee has exited and returns its exit code.
34    Exited(ExitedEventBody),
35
36    /// This event indicates that the debug adapter is ready to accept configuration requests (e.g. SetBreakpointsRequest, SetExceptionBreakpointsRequest).
37    ///
38    /// A debug adapter is expected to send this event when it is ready to accept configuration requests (but not before the 'initialize' request has finished).
39    ///
40    /// The sequence of events/requests is as follows:
41    ///
42    /// - adapters sends 'initialized' event (after the 'initialize' request has returned)
43    ///
44    /// - frontend sends zero or more 'setBreakpoints' requests
45    ///
46    /// - frontend sends one 'setFunctionBreakpoints' request (if capability 'supportsFunctionBreakpoints' is true)
47    ///
48    /// - frontend sends a 'setExceptionBreakpoints' request if one or more 'exceptionBreakpointFilters' have been defined (or if 'supportsConfigurationDoneRequest' is not defined or false)
49    ///
50    /// - frontend sends other future configuration requests
51    ///
52    /// - frontend sends one 'configurationDone' request to indicate the end of the configuration.
53    Initialized,
54
55    /// This event signals that some state in the debug adapter has changed and requires that the client needs to re-render the data snapshot previously requested.
56    ///
57    /// Debug adapters do not have to emit this event for runtime changes like stopped or thread events because in that case the client refetches the new state anyway. But the event can be used for example to refresh the UI after rendering formatting has changed in the debug adapter.
58    ///
59    /// This event should only be sent if the debug adapter has received a value true for the 'supportsInvalidatedEvent' capability of the 'initialize' request.
60    Invalidated(InvalidatedEventBody),
61
62    /// The event indicates that some source has been added, changed, or removed from the set of all loaded sources.
63    LoadedSource(LoadedSourceEventBody),
64
65    /// The event indicates that some information about a module has changed.
66    Module(ModuleEventBody),
67
68    /// The event indicates that the target has produced some output.
69    Output(OutputEventBody),
70
71    /// The event indicates that the debugger has begun debugging a new process. Either one that it has launched, or one that it has attached to.
72    Process(ProcessEventBody),
73
74    /// The event signals the end of the progress reporting with an optional final message.
75    ///
76    /// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request.
77    ProgressEnd(ProgressEndEventBody),
78
79    /// The event signals that a long running operation is about to start and
80    ///
81    /// provides additional information for the client to set up a corresponding progress and cancellation UI.
82    ///
83    /// The client is free to delay the showing of the UI in order to reduce flicker.
84    ///
85    /// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request.
86    ProgressStart(ProgressStartEventBody),
87
88    /// The event signals that the progress reporting needs to updated with a new message and/or percentage.
89    ///
90    /// The client does not have to update the UI immediately, but the clients needs to keep track of the message and/or percentage values.
91    ///
92    /// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request.
93    ProgressUpdate(ProgressUpdateEventBody),
94
95    /// The event indicates that the execution of the debuggee has stopped due to some condition.
96    ///
97    /// This can be caused by a break point previously set, a stepping request has completed, by executing a debugger statement etc.
98    Stopped(StoppedEventBody),
99
100    /// The event indicates that debugging of the debuggee has terminated. This does **not** mean that the debuggee itself has exited.
101    Terminated(TerminatedEventBody),
102
103    /// The event indicates that a thread has started or exited.
104    Thread(ThreadEventBody),
105}
106impl From<Event> for ProtocolMessageContent {
107    fn from(event: Event) -> Self {
108        Self::Event(event)
109    }
110}
111
112#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
113pub struct BreakpointEventBody {
114    /// The reason for the event.
115    #[serde(rename = "reason")]
116    pub reason: BreakpointEventReason,
117
118    /// The 'id' attribute is used to find the target breakpoint and the other attributes are used as the new values.
119    #[serde(rename = "breakpoint")]
120    pub breakpoint: Breakpoint,
121
122    #[serde(skip)]
123    #[builder(default, setter(skip))]
124    private: (),
125}
126impl From<BreakpointEventBody> for Event {
127    fn from(body: BreakpointEventBody) -> Self {
128        Self::Breakpoint(body)
129    }
130}
131impl From<BreakpointEventBody> for ProtocolMessageContent {
132    fn from(body: BreakpointEventBody) -> Self {
133        Self::from(Event::from(body))
134    }
135}
136
137/// The reason for the event.
138#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
139pub enum BreakpointEventReason {
140    #[serde(rename = "changed")]
141    Changed,
142
143    #[serde(rename = "new")]
144    New,
145
146    #[serde(rename = "removed")]
147    Removed,
148}
149
150#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
151pub struct CapabilitiesEventBody {
152    /// The set of updated capabilities.
153    #[serde(rename = "capabilities")]
154    pub capabilities: Capabilities,
155
156    #[serde(skip)]
157    #[builder(default, setter(skip))]
158    private: (),
159}
160impl From<CapabilitiesEventBody> for Event {
161    fn from(body: CapabilitiesEventBody) -> Self {
162        Self::Capabilities(body)
163    }
164}
165impl From<CapabilitiesEventBody> for ProtocolMessageContent {
166    fn from(body: CapabilitiesEventBody) -> Self {
167        Self::from(Event::from(body))
168    }
169}
170
171#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
172pub struct ContinuedEventBody {
173    /// The thread which was continued.
174    #[serde(rename = "threadId")]
175    pub thread_id: i32,
176
177    /// If 'allThreadsContinued' is true, a debug adapter can announce that all threads have continued.
178    #[serde(
179        rename = "allThreadsContinued",
180        default,
181        skip_serializing_if = "eq_default"
182    )]
183    #[builder(default)]
184    pub all_threads_continued: bool,
185
186    #[serde(skip)]
187    #[builder(default, setter(skip))]
188    private: (),
189}
190impl From<ContinuedEventBody> for Event {
191    fn from(body: ContinuedEventBody) -> Self {
192        Self::Continued(body)
193    }
194}
195impl From<ContinuedEventBody> for ProtocolMessageContent {
196    fn from(body: ContinuedEventBody) -> Self {
197        Self::from(Event::from(body))
198    }
199}
200
201#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
202pub struct ExitedEventBody {
203    /// The exit code returned from the debuggee.
204    #[serde(rename = "exitCode")]
205    pub exit_code: i32,
206
207    #[serde(skip)]
208    #[builder(default, setter(skip))]
209    private: (),
210}
211impl From<ExitedEventBody> for Event {
212    fn from(body: ExitedEventBody) -> Self {
213        Self::Exited(body)
214    }
215}
216impl From<ExitedEventBody> for ProtocolMessageContent {
217    fn from(body: ExitedEventBody) -> Self {
218        Self::from(Event::from(body))
219    }
220}
221
222#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
223pub struct InvalidatedEventBody {
224    /// Optional set of logical areas that got invalidated. This property has a hint characteristic: a client can only be expected to make a 'best effort' in honouring the areas but there are no guarantees. If this property is missing, empty, or if values are not understand the client should assume a single value 'all'.
225    #[serde(rename = "areas", default, skip_serializing_if = "Vec::is_empty")]
226    #[builder(default)]
227    pub areas: Vec<InvalidatedAreas>,
228
229    /// If specified, the client only needs to refetch data related to this thread.
230    #[serde(rename = "threadId", skip_serializing_if = "Option::is_none")]
231    #[builder(default)]
232    pub thread_id: Option<i32>,
233
234    /// If specified, the client only needs to refetch data related to this stack frame (and the 'threadId' is ignored).
235    #[serde(rename = "stackFrameId", skip_serializing_if = "Option::is_none")]
236    #[builder(default)]
237    pub stack_frame_id: Option<i32>,
238
239    #[serde(skip)]
240    #[builder(default, setter(skip))]
241    private: (),
242}
243impl From<InvalidatedEventBody> for Event {
244    fn from(body: InvalidatedEventBody) -> Self {
245        Self::Invalidated(body)
246    }
247}
248impl From<InvalidatedEventBody> for ProtocolMessageContent {
249    fn from(body: InvalidatedEventBody) -> Self {
250        Self::from(Event::from(body))
251    }
252}
253
254#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
255pub struct LoadedSourceEventBody {
256    /// The reason for the event.
257    #[serde(rename = "reason")]
258    pub reason: LoadedSourceEventReason,
259
260    /// The new, changed, or removed source.
261    #[serde(rename = "source")]
262    pub source: Source,
263
264    #[serde(skip)]
265    #[builder(default, setter(skip))]
266    private: (),
267}
268impl From<LoadedSourceEventBody> for Event {
269    fn from(body: LoadedSourceEventBody) -> Self {
270        Self::LoadedSource(body)
271    }
272}
273impl From<LoadedSourceEventBody> for ProtocolMessageContent {
274    fn from(body: LoadedSourceEventBody) -> Self {
275        Self::from(Event::from(body))
276    }
277}
278
279/// The reason for the event.
280#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
281pub enum LoadedSourceEventReason {
282    #[serde(rename = "new")]
283    New,
284
285    #[serde(rename = "changed")]
286    Changed,
287
288    #[serde(rename = "removed")]
289    Removed,
290}
291
292#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
293pub struct ModuleEventBody {
294    /// The reason for the event.
295    #[serde(rename = "reason")]
296    pub reason: ModuleEventReason,
297
298    /// The new, changed, or removed module. In case of 'removed' only the module id is used.
299    #[serde(rename = "module")]
300    pub module: Module,
301
302    #[serde(skip)]
303    #[builder(default, setter(skip))]
304    private: (),
305}
306impl From<ModuleEventBody> for Event {
307    fn from(body: ModuleEventBody) -> Self {
308        Self::Module(body)
309    }
310}
311impl From<ModuleEventBody> for ProtocolMessageContent {
312    fn from(body: ModuleEventBody) -> Self {
313        Self::from(Event::from(body))
314    }
315}
316
317/// The reason for the event.
318#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
319pub enum ModuleEventReason {
320    #[serde(rename = "new")]
321    New,
322
323    #[serde(rename = "changed")]
324    Changed,
325
326    #[serde(rename = "removed")]
327    Removed,
328}
329
330#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
331pub struct OutputEventBody {
332    /// The output category. If not specified, 'console' is assumed.
333    #[serde(rename = "category", default, skip_serializing_if = "eq_default")]
334    #[builder(default)]
335    pub category: OutputCategory,
336
337    /// The output to report.
338    #[serde(rename = "output")]
339    pub output: String,
340
341    /// Support for keeping an output log organized by grouping related messages.
342    #[serde(rename = "group", skip_serializing_if = "Option::is_none")]
343    #[builder(default)]
344    pub group: Option<OutputGroup>,
345
346    /// If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request. The value should be less than or equal to 2147483647 (2^31-1).
347    #[serde(rename = "variablesReference", skip_serializing_if = "Option::is_none")]
348    #[builder(default)]
349    pub variables_reference: Option<i32>,
350
351    /// An optional source location where the output was produced.
352    #[serde(rename = "source", skip_serializing_if = "Option::is_none")]
353    #[builder(default)]
354    pub source: Option<Source>,
355
356    /// An optional source location line where the output was produced.
357    #[serde(rename = "line", skip_serializing_if = "Option::is_none")]
358    #[builder(default)]
359    pub line: Option<i32>,
360
361    /// An optional source location column where the output was produced.
362    #[serde(rename = "column", skip_serializing_if = "Option::is_none")]
363    #[builder(default)]
364    pub column: Option<i32>,
365
366    /// Optional data to report. For the 'telemetry' category the data will be sent to telemetry, for the other categories the data is shown in JSON format.
367    #[serde(rename = "data", skip_serializing_if = "Option::is_none")]
368    #[builder(default)]
369    pub data: Option<Value>,
370
371    #[serde(skip)]
372    #[builder(default, setter(skip))]
373    private: (),
374}
375impl From<OutputEventBody> for Event {
376    fn from(body: OutputEventBody) -> Self {
377        Self::Output(body)
378    }
379}
380impl From<OutputEventBody> for ProtocolMessageContent {
381    fn from(body: OutputEventBody) -> Self {
382        Self::from(Event::from(body))
383    }
384}
385
386/// The output category. If not specified, 'console' is assumed.
387#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
388pub enum OutputCategory {
389    /// Show the output in the client's default message UI, e.g. a 'debug console'. This category should only be used for informational output from the debugger (as opposed to the debuggee).
390    #[serde(rename = "console")]
391    Console,
392
393    /// A hint for the client to show the ouput in the client's UI for important and highly visible information, e.g. as a popup notification. This category should only be used for important messages from the debugger (as opposed to the debuggee). Since this category value is a hint, clients might ignore the hint and assume the 'console' category.
394    #[serde(rename = "important")]
395    Important,
396
397    /// Show the output as normal program output from the debuggee.
398    #[serde(rename = "stdout")]
399    Stdout,
400
401    /// Show the output as error program output from the debuggee.
402    #[serde(rename = "stderr")]
403    Stderr,
404
405    /// Send the output to telemetry instead of showing it to the user.
406    #[serde(rename = "telemetry")]
407    Telemetry,
408}
409
410impl Default for OutputCategory {
411    fn default() -> Self {
412        OutputCategory::Console
413    }
414}
415
416/// Support for keeping an output log organized by grouping related messages.
417#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
418pub enum OutputGroup {
419    /// Start a new group in expanded mode. Subsequent output events are members of the group and should be shown indented.
420    ///
421    /// The 'output' attribute becomes the name of the group and is not indented.
422    #[serde(rename = "start")]
423    Start,
424
425    /// Start a new group in collapsed mode. Subsequent output events are members of the group and should be shown indented (as soon as the group is expanded).
426    ///
427    /// The 'output' attribute becomes the name of the group and is not indented.
428    #[serde(rename = "startCollapsed")]
429    StartCollapsed,
430
431    /// End the current group and decreases the indentation of subsequent output events.
432    ///
433    /// A non empty 'output' attribute is shown as the unindented end of the group.
434    #[serde(rename = "end")]
435    End,
436}
437
438#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
439pub struct ProcessEventBody {
440    /// The logical name of the process. This is usually the full path to process's executable file. Example: /home/example/myproj/program.js.
441    #[serde(rename = "name")]
442    pub name: String,
443
444    /// The system process id of the debugged process. This property will be missing for non-system processes.
445    #[serde(rename = "systemProcessId", skip_serializing_if = "Option::is_none")]
446    #[builder(default)]
447    pub system_process_id: Option<i32>,
448
449    /// If true, the process is running on the same computer as the debug adapter.
450    #[serde(rename = "isLocalProcess", skip_serializing_if = "Option::is_none")]
451    #[builder(default)]
452    pub is_local_process: Option<bool>,
453
454    /// Describes how the debug engine started debugging this process.
455    #[serde(rename = "startMethod", skip_serializing_if = "Option::is_none")]
456    #[builder(default)]
457    pub start_method: Option<ProcessStartMethod>,
458
459    /// The size of a pointer or address for this process, in bits. This value may be used by clients when formatting addresses for display.
460    #[serde(rename = "pointerSize", skip_serializing_if = "Option::is_none")]
461    #[builder(default)]
462    pub pointer_size: Option<i32>,
463
464    #[serde(skip)]
465    #[builder(default, setter(skip))]
466    private: (),
467}
468impl From<ProcessEventBody> for Event {
469    fn from(body: ProcessEventBody) -> Self {
470        Self::Process(body)
471    }
472}
473impl From<ProcessEventBody> for ProtocolMessageContent {
474    fn from(body: ProcessEventBody) -> Self {
475        Self::from(Event::from(body))
476    }
477}
478
479/// Describes how the debug engine started debugging this process.
480#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
481pub enum ProcessStartMethod {
482    /// Process was launched under the debugger.
483    #[serde(rename = "launch")]
484    Launch,
485
486    /// Debugger attached to an existing process.
487    #[serde(rename = "attach")]
488    Attach,
489
490    /// A project launcher component has launched a new process in a suspended state and then asked the debugger to attach.
491    #[serde(rename = "attachForSuspendedLaunch")]
492    AttachForSuspendedLaunch,
493}
494
495#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
496pub struct ProgressEndEventBody {
497    /// The ID that was introduced in the initial 'ProgressStartEvent'.
498    #[serde(rename = "progressId")]
499    pub progress_id: String,
500
501    /// Optional, more detailed progress message. If omitted, the previous message (if any) is used.
502    #[serde(rename = "message", skip_serializing_if = "Option::is_none")]
503    #[builder(default)]
504    pub message: Option<String>,
505
506    #[serde(skip)]
507    #[builder(default, setter(skip))]
508    private: (),
509}
510impl From<ProgressEndEventBody> for Event {
511    fn from(body: ProgressEndEventBody) -> Self {
512        Self::ProgressEnd(body)
513    }
514}
515impl From<ProgressEndEventBody> for ProtocolMessageContent {
516    fn from(body: ProgressEndEventBody) -> Self {
517        Self::from(Event::from(body))
518    }
519}
520
521#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
522pub struct ProgressStartEventBody {
523    /// An ID that must be used in subsequent 'progressUpdate' and 'progressEnd' events to make them refer to the same progress reporting.
524    ///
525    /// IDs must be unique within a debug session.
526    #[serde(rename = "progressId")]
527    pub progress_id: String,
528
529    /// Mandatory (short) title of the progress reporting. Shown in the UI to describe the long running operation.
530    #[serde(rename = "title")]
531    pub title: String,
532
533    /// The request ID that this progress report is related to. If specified a debug adapter is expected to emit
534    ///
535    /// progress events for the long running request until the request has been either completed or cancelled.
536    ///
537    /// If the request ID is omitted, the progress report is assumed to be related to some general activity of the debug adapter.
538    #[serde(rename = "requestId", skip_serializing_if = "Option::is_none")]
539    #[builder(default)]
540    pub request_id: Option<i32>,
541
542    /// If true, the request that reports progress may be canceled with a 'cancel' request.
543    ///
544    /// So this property basically controls whether the client should use UX that supports cancellation.
545    ///
546    /// Clients that don't support cancellation are allowed to ignore the setting.
547    #[serde(rename = "cancellable", default, skip_serializing_if = "eq_default")]
548    #[builder(default)]
549    pub cancellable: bool,
550
551    /// Optional, more detailed progress message.
552    #[serde(rename = "message", skip_serializing_if = "Option::is_none")]
553    #[builder(default)]
554    pub message: Option<String>,
555
556    /// Optional progress percentage to display (value range: 0 to 100). If omitted no percentage will be shown.
557    #[serde(rename = "percentage", skip_serializing_if = "Option::is_none")]
558    #[builder(default)]
559    pub percentage: Option<u8>,
560
561    #[serde(skip)]
562    #[builder(default, setter(skip))]
563    private: (),
564}
565impl From<ProgressStartEventBody> for Event {
566    fn from(body: ProgressStartEventBody) -> Self {
567        Self::ProgressStart(body)
568    }
569}
570impl From<ProgressStartEventBody> for ProtocolMessageContent {
571    fn from(body: ProgressStartEventBody) -> Self {
572        Self::from(Event::from(body))
573    }
574}
575
576#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
577pub struct ProgressUpdateEventBody {
578    /// The ID that was introduced in the initial 'progressStart' event.
579    #[serde(rename = "progressId")]
580    pub progress_id: String,
581
582    /// Optional, more detailed progress message. If omitted, the previous message (if any) is used.
583    #[serde(rename = "message", skip_serializing_if = "Option::is_none")]
584    #[builder(default)]
585    pub message: Option<String>,
586
587    /// Optional progress percentage to display (value range: 0 to 100). If omitted no percentage will be shown.
588    #[serde(rename = "percentage", skip_serializing_if = "Option::is_none")]
589    #[builder(default)]
590    pub percentage: Option<u8>,
591
592    #[serde(skip)]
593    #[builder(default, setter(skip))]
594    private: (),
595}
596impl From<ProgressUpdateEventBody> for Event {
597    fn from(body: ProgressUpdateEventBody) -> Self {
598        Self::ProgressUpdate(body)
599    }
600}
601impl From<ProgressUpdateEventBody> for ProtocolMessageContent {
602    fn from(body: ProgressUpdateEventBody) -> Self {
603        Self::from(Event::from(body))
604    }
605}
606
607#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
608pub struct StoppedEventBody {
609    /// The reason for the event.
610    ///
611    /// For backward compatibility this string is shown in the UI if the 'description' attribute is missing (but it must not be translated).
612    #[serde(rename = "reason")]
613    pub reason: StoppedEventReason,
614
615    /// The full reason for the event, e.g. 'Paused on exception'. This string is shown in the UI as is and must be translated.
616    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
617    #[builder(default)]
618    pub description: Option<String>,
619
620    /// The thread which was stopped.
621    #[serde(rename = "threadId", skip_serializing_if = "Option::is_none")]
622    #[builder(default)]
623    pub thread_id: Option<i32>,
624
625    /// A value of true hints to the frontend that this event should not change the focus.
626    #[serde(
627        rename = "preserveFocusHint",
628        default,
629        skip_serializing_if = "eq_default"
630    )]
631    #[builder(default)]
632    pub preserve_focus_hint: bool,
633
634    /// Additional information. E.g. if reason is 'exception', text contains the exception name. This string is shown in the UI.
635    #[serde(rename = "text", skip_serializing_if = "Option::is_none")]
636    #[builder(default)]
637    pub text: Option<String>,
638
639    /// If 'allThreadsStopped' is true, a debug adapter can announce that all threads have stopped.
640    ///
641    /// - The client should use this information to enable that all threads can be expanded to access their stacktraces.
642    ///
643    /// - If the attribute is missing or false, only the thread with the given threadId can be expanded.
644    #[serde(
645        rename = "allThreadsStopped",
646        default,
647        skip_serializing_if = "eq_default"
648    )]
649    #[builder(default)]
650    pub all_threads_stopped: bool,
651
652    /// Ids of the breakpoints that triggered the event. In most cases there will be only a single breakpoint but here are some examples for multiple breakpoints:
653    ///
654    /// - Different types of breakpoints map to the same location.
655    ///
656    /// - Multiple source breakpoints get collapsed to the same instruction by the compiler/runtime.
657    ///
658    /// - Multiple function breakpoints with different function names map to the same location.
659    #[serde(
660        rename = "hitBreakpointIds",
661        default,
662        skip_serializing_if = "Vec::is_empty"
663    )]
664    #[builder(default)]
665    pub hit_breakpoint_ids: Vec<i32>,
666
667    #[serde(skip)]
668    #[builder(default, setter(skip))]
669    private: (),
670}
671impl From<StoppedEventBody> for Event {
672    fn from(body: StoppedEventBody) -> Self {
673        Self::Stopped(body)
674    }
675}
676impl From<StoppedEventBody> for ProtocolMessageContent {
677    fn from(body: StoppedEventBody) -> Self {
678        Self::from(Event::from(body))
679    }
680}
681
682/// The reason for the event.
683///
684/// For backward compatibility this string is shown in the UI if the 'description' attribute is missing (but it must not be translated).
685#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
686pub enum StoppedEventReason {
687    #[serde(rename = "step")]
688    Step,
689
690    #[serde(rename = "breakpoint")]
691    Breakpoint,
692
693    #[serde(rename = "exception")]
694    Exception,
695
696    #[serde(rename = "pause")]
697    Pause,
698
699    #[serde(rename = "entry")]
700    Entry,
701
702    #[serde(rename = "goto")]
703    Goto,
704
705    #[serde(rename = "function breakpoint")]
706    FunctionBreakpoint,
707
708    #[serde(rename = "data breakpoint")]
709    DataBreakpoint,
710
711    #[serde(rename = "instruction breakpoint")]
712    InstructionBreakpoint,
713}
714
715#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
716pub struct TerminatedEventBody {
717    /// A debug adapter may set 'restart' to true (or to an arbitrary object) to request that the front end restarts the session.
718    ///
719    /// The value is not interpreted by the client and passed unmodified as an attribute '__restart' to the 'launch' and 'attach' requests.
720    #[serde(rename = "restart", skip_serializing_if = "Option::is_none")]
721    #[builder(default)]
722    pub restart: Option<Value>,
723
724    #[serde(skip)]
725    #[builder(default, setter(skip))]
726    private: (),
727}
728impl From<TerminatedEventBody> for Event {
729    fn from(body: TerminatedEventBody) -> Self {
730        Self::Terminated(body)
731    }
732}
733impl From<TerminatedEventBody> for ProtocolMessageContent {
734    fn from(body: TerminatedEventBody) -> Self {
735        Self::from(Event::from(body))
736    }
737}
738
739#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
740pub struct ThreadEventBody {
741    /// The reason for the event.
742    #[serde(rename = "reason")]
743    pub reason: ThreadEventReason,
744
745    /// The identifier of the thread.
746    #[serde(rename = "threadId")]
747    pub thread_id: i32,
748
749    #[serde(skip)]
750    #[builder(default, setter(skip))]
751    private: (),
752}
753impl From<ThreadEventBody> for Event {
754    fn from(body: ThreadEventBody) -> Self {
755        Self::Thread(body)
756    }
757}
758impl From<ThreadEventBody> for ProtocolMessageContent {
759    fn from(body: ThreadEventBody) -> Self {
760        Self::from(Event::from(body))
761    }
762}
763
764/// The reason for the event.
765#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
766pub enum ThreadEventReason {
767    #[serde(rename = "started")]
768    Started,
769
770    #[serde(rename = "exited")]
771    Exited,
772}