lsp_types_max/progress.rs
1use serde::{Deserialize, Serialize};
2
3use crate::NumberOrString;
4
5pub type ProgressToken = NumberOrString;
6
7/// The progress notification is sent from the server to the client to ask
8/// the client to indicate progress.
9#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
10#[serde(rename_all = "camelCase")]
11pub struct ProgressParams {
12 /// The progress token provided by the client.
13 pub token: ProgressToken,
14
15 /// The progress data.
16 pub value: ProgressParamsValue,
17}
18
19#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
20#[serde(untagged)]
21pub enum ProgressParamsValue {
22 WorkDone(WorkDoneProgress),
23}
24
25/// The `window/workDoneProgress/create` request is sent
26/// from the server to the client to ask the client to create a work done progress.
27#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
28#[serde(rename_all = "camelCase")]
29pub struct WorkDoneProgressCreateParams {
30 /// The token to be used to report progress.
31 pub token: ProgressToken,
32}
33
34/// The `window/workDoneProgress/cancel` notification is sent from the client
35/// to the server to cancel a progress initiated on the server side using the `window/workDoneProgress/create`.
36#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
37#[serde(rename_all = "camelCase")]
38pub struct WorkDoneProgressCancelParams {
39 /// The token to be used to report progress.
40 pub token: ProgressToken,
41}
42
43/// An optional token that a server can use to report work done progress
44#[derive(Debug, Eq, PartialEq, Default, Deserialize, Serialize, Clone)]
45#[serde(rename_all = "camelCase")]
46pub struct WorkDoneProgressParams {
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub work_done_token: Option<ProgressToken>,
49}
50
51#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
52#[serde(rename_all = "camelCase")]
53pub struct WorkDoneProgressBegin {
54 /// Mandatory title of the progress operation. Used to briefly inform
55 /// about the kind of operation being performed.
56 /// Examples: "Indexing" or "Linking dependencies".
57 pub title: String,
58
59 /// Controls if a cancel button should show to allow the user to cancel the
60 /// long running operation. Clients that don't support cancellation are allowed
61 /// to ignore the setting.
62 #[serde(skip_serializing_if = "Option::is_none")]
63 pub cancellable: Option<bool>,
64
65 /// Optional, more detailed associated progress message. Contains
66 /// complementary information to the `title`.
67 ///
68 /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
69 /// If unset, the previous progress message (if any) is still valid.
70 #[serde(skip_serializing_if = "Option::is_none")]
71 pub message: Option<String>,
72
73 /// Optional progress percentage to display (value 100 is considered 100%).
74 /// If not provided infinite progress is assumed and clients are allowed
75 /// to ignore the `percentage` value in subsequent in report notifications.
76 ///
77 /// The value should be steadily rising. Clients are free to ignore values
78 /// that are not following this rule. The value range is [0, 100]
79 #[serde(skip_serializing_if = "Option::is_none")]
80 pub percentage: Option<u32>,
81}
82
83#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
84#[serde(rename_all = "camelCase")]
85pub struct WorkDoneProgressReport {
86 /// Controls if a cancel button should show to allow the user to cancel the
87 /// long running operation. Clients that don't support cancellation are allowed
88 /// to ignore the setting.
89 #[serde(skip_serializing_if = "Option::is_none")]
90 pub cancellable: Option<bool>,
91
92 /// Optional, more detailed associated progress message. Contains
93 /// complementary information to the `title`.
94 /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
95 /// If unset, the previous progress message (if any) is still valid.
96 #[serde(skip_serializing_if = "Option::is_none")]
97 pub message: Option<String>,
98
99 /// Optional progress percentage to display (value 100 is considered 100%).
100 /// If not provided infinite progress is assumed and clients are allowed
101 /// to ignore the `percentage` value in subsequent in report notifications.
102 ///
103 /// The value should be steadily rising. Clients are free to ignore values
104 /// that are not following this rule. The value range is [0, 100]
105 #[serde(skip_serializing_if = "Option::is_none")]
106 pub percentage: Option<u32>,
107}
108
109#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
110#[serde(rename_all = "camelCase")]
111pub struct WorkDoneProgressEnd {
112 /// Optional, more detailed associated progress message. Contains
113 /// complementary information to the `title`.
114 /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
115 /// If unset, the previous progress message (if any) is still valid.
116 #[serde(skip_serializing_if = "Option::is_none")]
117 pub message: Option<String>,
118}
119
120#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
121#[serde(tag = "kind", rename_all = "lowercase")]
122pub enum WorkDoneProgress {
123 Begin(WorkDoneProgressBegin),
124 Report(WorkDoneProgressReport),
125 End(WorkDoneProgressEnd),
126}