Skip to main content

lsp_max/service/client/
progress_ext.rs

1//! Extensions for Progress and Cancellation.
2
3use lsp_types_max::notification::{Cancel, SetTrace, WorkDoneProgressCancel};
4use lsp_types_max::{
5    CancelParams, NumberOrString, ProgressToken, SetTraceParams, TraceValue,
6    WorkDoneProgressCancelParams,
7};
8
9use super::Client;
10
11impl Client {
12    /// Sends a `$/cancelRequest` notification to the client.
13    ///
14    /// This notification is sent from the server to the client to cancel a specific request
15    /// previously sent by the server.
16    ///
17    /// # Initialization
18    ///
19    /// This notification will only be sent if the server is initialized.
20    pub async fn cancel_request(&self, id: NumberOrString) {
21        self.send_notification::<Cancel>(CancelParams { id }).await;
22    }
23
24    /// Sends a `window/workDoneProgress/cancel` notification to the client.
25    ///
26    /// This notification is sent from the server to the client to inform it that the server
27    /// has cancelled a specific work done progress.
28    ///
29    /// # Initialization
30    ///
31    /// This notification will only be sent if the server is initialized.
32    pub async fn work_done_progress_cancel(&self, token: ProgressToken) {
33        self.send_notification::<WorkDoneProgressCancel>(WorkDoneProgressCancelParams { token })
34            .await;
35    }
36
37    /// Sends a `$/setTrace` notification to the client.
38    ///
39    /// This notification is used to modify the trace setting of the client.
40    ///
41    /// # Initialization
42    ///
43    /// This notification will only be sent if the server is initialized.
44    pub async fn set_trace(&self, value: TraceValue) {
45        self.send_notification::<SetTrace>(SetTraceParams { value })
46            .await;
47    }
48}