| 1 | use serde::{Deserialize, Serialize}; |
| 2 | |
| 3 | use crate::NumberOrString; |
| 4 | |
| 5 | pub 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" )] |
| 11 | pub 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)] |
| 21 | pub 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" )] |
| 29 | pub 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" )] |
| 38 | pub struct WorkDoneProgressCancelParams { |
| 39 | /// The token to be used to report progress. |
| 40 | pub token: ProgressToken, |
| 41 | } |
| 42 | |
| 43 | /// Options to signal work done progress support in server capabilities. |
| 44 | #[derive (Debug, Eq, PartialEq, Default, Deserialize, Serialize, Clone)] |
| 45 | #[serde(rename_all = "camelCase" )] |
| 46 | pub struct WorkDoneProgressOptions { |
| 47 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 48 | pub work_done_progress: Option<bool>, |
| 49 | } |
| 50 | |
| 51 | /// An optional token that a server can use to report work done progress |
| 52 | #[derive (Debug, Eq, PartialEq, Default, Deserialize, Serialize, Clone)] |
| 53 | #[serde(rename_all = "camelCase" )] |
| 54 | pub struct WorkDoneProgressParams { |
| 55 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 56 | pub work_done_token: Option<ProgressToken>, |
| 57 | } |
| 58 | |
| 59 | #[derive (Debug, PartialEq, Default, Deserialize, Serialize, Clone)] |
| 60 | #[serde(rename_all = "camelCase" )] |
| 61 | pub struct WorkDoneProgressBegin { |
| 62 | /// Mandatory title of the progress operation. Used to briefly inform |
| 63 | /// about the kind of operation being performed. |
| 64 | /// Examples: "Indexing" or "Linking dependencies". |
| 65 | pub title: String, |
| 66 | |
| 67 | /// Controls if a cancel button should show to allow the user to cancel the |
| 68 | /// long running operation. Clients that don't support cancellation are allowed |
| 69 | /// to ignore the setting. |
| 70 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 71 | pub cancellable: Option<bool>, |
| 72 | |
| 73 | /// Optional, more detailed associated progress message. Contains |
| 74 | /// complementary information to the `title`. |
| 75 | /// |
| 76 | /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". |
| 77 | /// If unset, the previous progress message (if any) is still valid. |
| 78 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 79 | pub message: Option<String>, |
| 80 | |
| 81 | /// Optional progress percentage to display (value 100 is considered 100%). |
| 82 | /// If not provided infinite progress is assumed and clients are allowed |
| 83 | /// to ignore the `percentage` value in subsequent in report notifications. |
| 84 | /// |
| 85 | /// The value should be steadily rising. Clients are free to ignore values |
| 86 | /// that are not following this rule. The value range is [0, 100] |
| 87 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 88 | pub percentage: Option<u32>, |
| 89 | } |
| 90 | |
| 91 | #[derive (Debug, PartialEq, Default, Deserialize, Serialize, Clone)] |
| 92 | #[serde(rename_all = "camelCase" )] |
| 93 | pub struct WorkDoneProgressReport { |
| 94 | /// Controls if a cancel button should show to allow the user to cancel the |
| 95 | /// long running operation. Clients that don't support cancellation are allowed |
| 96 | /// to ignore the setting. |
| 97 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 98 | pub cancellable: Option<bool>, |
| 99 | |
| 100 | /// Optional, more detailed associated progress message. Contains |
| 101 | /// complementary information to the `title`. |
| 102 | /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". |
| 103 | /// If unset, the previous progress message (if any) is still valid. |
| 104 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 105 | pub message: Option<String>, |
| 106 | |
| 107 | /// Optional progress percentage to display (value 100 is considered 100%). |
| 108 | /// If not provided infinite progress is assumed and clients are allowed |
| 109 | /// to ignore the `percentage` value in subsequent in report notifications. |
| 110 | /// |
| 111 | /// The value should be steadily rising. Clients are free to ignore values |
| 112 | /// that are not following this rule. The value range is [0, 100] |
| 113 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 114 | pub percentage: Option<u32>, |
| 115 | } |
| 116 | |
| 117 | #[derive (Debug, PartialEq, Default, Deserialize, Serialize, Clone)] |
| 118 | #[serde(rename_all = "camelCase" )] |
| 119 | pub struct WorkDoneProgressEnd { |
| 120 | /// Optional, more detailed associated progress message. Contains |
| 121 | /// complementary information to the `title`. |
| 122 | /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". |
| 123 | /// If unset, the previous progress message (if any) is still valid. |
| 124 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 125 | pub message: Option<String>, |
| 126 | } |
| 127 | |
| 128 | #[derive (Debug, PartialEq, Deserialize, Serialize, Clone)] |
| 129 | #[serde(tag = "kind" , rename_all = "lowercase" )] |
| 130 | pub enum WorkDoneProgress { |
| 131 | Begin(WorkDoneProgressBegin), |
| 132 | Report(WorkDoneProgressReport), |
| 133 | End(WorkDoneProgressEnd), |
| 134 | } |
| 135 | |