pub struct Client { /* private fields */ }
Expand description
Handle for communicating with the language client.
This type provides a very cheap implementation of Clone
so API consumers can cheaply clone
and pass it around as needed.
It also implements tower::Service
in order to remain independent from the underlying
transport and to facilitate further abstraction with middleware.
Implementations§
source§impl Client
impl Client
sourcepub async fn register_capability(
&self,
registrations: Vec<Registration>,
) -> Result<()>
pub async fn register_capability( &self, registrations: Vec<Registration>, ) -> Result<()>
Registers a new capability with the client.
This corresponds to the client/registerCapability
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
sourcepub async fn unregister_capability(
&self,
unregisterations: Vec<Unregistration>,
) -> Result<()>
pub async fn unregister_capability( &self, unregisterations: Vec<Unregistration>, ) -> Result<()>
Unregisters a capability with the client.
This corresponds to the client/unregisterCapability
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
sourcepub async fn show_message<M: Display>(&self, typ: MessageType, message: M)
pub async fn show_message<M: Display>(&self, typ: MessageType, message: M)
Notifies the client to display a particular message in the user interface.
This corresponds to the window/showMessage
notification.
sourcepub async fn show_message_request<M: Display>(
&self,
typ: MessageType,
message: M,
actions: Option<Vec<MessageActionItem>>,
) -> Result<Option<MessageActionItem>>
pub async fn show_message_request<M: Display>( &self, typ: MessageType, message: M, actions: Option<Vec<MessageActionItem>>, ) -> Result<Option<MessageActionItem>>
Requests the client to display a particular message in the user interface.
Unlike the show_message
notification, this request can also pass a list of actions and
wait for an answer from the client.
This corresponds to the window/showMessageRequest
request.
sourcepub async fn log_message<M: Display>(&self, typ: MessageType, message: M)
pub async fn log_message<M: Display>(&self, typ: MessageType, message: M)
Notifies the client to log a particular message.
This corresponds to the window/logMessage
notification.
sourcepub async fn show_document(&self, params: ShowDocumentParams) -> Result<bool>
pub async fn show_document(&self, params: ShowDocumentParams) -> Result<bool>
Asks the client to display a particular resource referenced by a URI in the user interface.
Returns Ok(true)
if the document was successfully shown, or Ok(false)
otherwise.
This corresponds to the window/showDocument
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.16.0.
sourcepub async fn telemetry_event<S: Serialize>(&self, data: S)
pub async fn telemetry_event<S: Serialize>(&self, data: S)
Notifies the client to log a telemetry event.
This corresponds to the telemetry/event
notification.
sourcepub async fn code_lens_refresh(&self) -> Result<()>
pub async fn code_lens_refresh(&self) -> Result<()>
Asks the client to refresh the code lenses currently shown in editors. As a result, the client should ask the server to recompute the code lenses for these editors.
This is useful if a server detects a configuration change which requires a re-calculation of all code lenses.
Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible.
This corresponds to the workspace/codeLens/refresh
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.16.0.
sourcepub async fn semantic_tokens_refresh(&self) -> Result<()>
pub async fn semantic_tokens_refresh(&self) -> Result<()>
Asks the client to refresh the editors for which this server provides semantic tokens. As a result, the client should ask the server to recompute the semantic tokens for these editors.
This is useful if a server detects a project-wide configuration change which requires a re-calculation of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible.
This corresponds to the workspace/semanticTokens/refresh
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.16.0.
sourcepub async fn inline_value_refresh(&self) -> Result<()>
pub async fn inline_value_refresh(&self) -> Result<()>
Asks the client to refresh the inline values currently shown in editors. As a result, the client should ask the server to recompute the inline values for these editors.
This is useful if a server detects a configuration change which requires a re-calculation of all inline values. Note that the client still has the freedom to delay the re-calculation of the inline values if for example an editor is currently not visible.
This corresponds to the workspace/inlineValue/refresh
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.17.0.
sourcepub async fn inlay_hint_refresh(&self) -> Result<()>
pub async fn inlay_hint_refresh(&self) -> Result<()>
Asks the client to refresh the inlay hints currently shown in editors. As a result, the client should ask the server to recompute the inlay hints for these editors.
This is useful if a server detects a configuration change which requires a re-calculation of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints if for example an editor is currently not visible.
This corresponds to the workspace/inlayHint/refresh
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.17.0.
sourcepub async fn workspace_diagnostic_refresh(&self) -> Result<()>
pub async fn workspace_diagnostic_refresh(&self) -> Result<()>
Asks the client to refresh all needed document and workspace diagnostics.
This is useful if a server detects a project wide configuration change which requires a re-calculation of all diagnostics.
This corresponds to the workspace/diagnostic/refresh
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.17.0.
sourcepub async fn publish_diagnostics(
&self,
uri: Url,
diags: Vec<Diagnostic>,
version: Option<i32>,
)
pub async fn publish_diagnostics( &self, uri: Url, diags: Vec<Diagnostic>, version: Option<i32>, )
Submits validation diagnostics for an open file with the given URI.
This corresponds to the textDocument/publishDiagnostics
notification.
§Initialization
This notification will only be sent if the server is initialized.
sourcepub async fn configuration(
&self,
items: Vec<ConfigurationItem>,
) -> Result<Vec<Value>>
pub async fn configuration( &self, items: Vec<ConfigurationItem>, ) -> Result<Vec<Value>>
Fetches configuration settings from the client.
The request can fetch several configuration settings in one roundtrip. The order of the
returned configuration settings correspond to the order of the passed
ConfigurationItem
s (e.g. the first item in the response is the result for the first
configuration item in the params).
This corresponds to the workspace/configuration
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.6.0.
sourcepub async fn workspace_folders(&self) -> Result<Option<Vec<WorkspaceFolder>>>
pub async fn workspace_folders(&self) -> Result<Option<Vec<WorkspaceFolder>>>
Fetches the current open list of workspace folders.
Returns None
if only a single file is open in the tool. Returns an empty Vec
if a
workspace is open but no folders are configured.
This corresponds to the workspace/workspaceFolders
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
§Compatibility
This request was introduced in specification version 3.6.0.
sourcepub async fn apply_edit(
&self,
edit: WorkspaceEdit,
) -> Result<ApplyWorkspaceEditResponse>
pub async fn apply_edit( &self, edit: WorkspaceEdit, ) -> Result<ApplyWorkspaceEditResponse>
Requests a workspace resource be edited on the client side and returns whether the edit was applied.
This corresponds to the workspace/applyEdit
request.
§Initialization
If the request is sent to the client before the server has been initialized, this will
immediately return Err
with JSON-RPC error code -32002
(read more).
sourcepub async fn send_notification<N>(&self, params: N::Params)where
N: Notification,
pub async fn send_notification<N>(&self, params: N::Params)where
N: Notification,
Sends a custom notification to the client.
§Initialization
This notification will only be sent if the server is initialized.
Trait Implementations§
source§impl Service<Request> for Client
impl Service<Request> for Client
§type Error = ExitedError
type Error = ExitedError
§type Future = Pin<Box<dyn Future<Output = Result<<Client as Service<Request>>::Response, <Client as Service<Request>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<Client as Service<Request>>::Response, <Client as Service<Request>>::Error>> + Send>>
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
ServiceExt::ready
method insteadsource§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service
, calling with the providing request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready
method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready
method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready
method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read moresource§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
source§fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
AsyncFilter
that conditionally accepts or
rejects requests based on an [async predicate]. Read more