pub struct LspClient { /* private fields */ }Expand description
LSP client with async request/response handling.
This client manages communication with an LSP server, handling:
- Concurrent requests with unique ID tracking
- Background message loop for receiving responses
- Timeout support for all requests
- Graceful shutdown
Implementations§
Source§impl LspClient
impl LspClient
Sourcepub fn new(config: LspServerConfig) -> Self
pub fn new(config: LspServerConfig) -> Self
Create a new LSP client with the given configuration.
The client starts in an uninitialized state. Call initialize() to
start the server and complete the initialization handshake.
Sourcepub fn language_id(&self) -> &str
pub fn language_id(&self) -> &str
Get the language ID for this client.
Sourcepub async fn state(&self) -> ServerState
pub async fn state(&self) -> ServerState
Get the current server state.
Sourcepub async fn request<P, R>(
&self,
method: &str,
params: P,
timeout_duration: Duration,
) -> Result<R>where
P: Serialize,
R: DeserializeOwned,
pub async fn request<P, R>(
&self,
method: &str,
params: P,
timeout_duration: Duration,
) -> Result<R>where
P: Serialize,
R: DeserializeOwned,
Send request and wait for response with timeout.
§Type Parameters
P- The type of the request parameters (must be serializable)R- The type of the response result (must be deserializable)
§Errors
Returns an error if:
- Server has shut down
- Request times out
- Response cannot be deserialized
- LSP server returns an error
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LspClient
impl !RefUnwindSafe for LspClient
impl Send for LspClient
impl Sync for LspClient
impl Unpin for LspClient
impl !UnwindSafe for LspClient
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
Mutably borrows from an owned value. Read more