You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like a design oversight that the Client type does not implement the tower_service::Service trait. Implementing this trait would enable compatibility with the tower middleware, and hopefully simplify the request dispatching logic.
Unlike LspService as described in issue #177, Client should be perfectly capable of having a unary request/response model. In this case, the Request type parameter would be ClientRequest and the associated types would be as follows:
typeResponse = Option<Response>;// Response is `None` if the request was a notification.typeError = crate::jsonrpc::Error;typeFuture = Pin<Box<dynFuture<Output = Result<Self::Response,Self::Error>> + Send>>;
It would be great if it were possible to implement Service generically, specializing over R: lsp_types::Request and N: lsp_types::Notification and accepting Params from both as input, but this is impossible to express in the Rust type system, as far as I can tell. I think the above approach is good enough solution for our use case.
We should think about whether ClientRequest should be redesigned to not include the id field for requests, in favor of having the Client manage it internally instead, using the request_id field. This prevents callers from submitting the same request ID twice, preventing accidental collisions and improving type safety.
The text was updated successfully, but these errors were encountered:
It seems like a design oversight that the
Client
type does not implement thetower_service::Service
trait. Implementing this trait would enable compatibility with thetower
middleware, and hopefully simplify the request dispatching logic.Unlike
LspService
as described in issue #177,Client
should be perfectly capable of having a unary request/response model. In this case, theRequest
type parameter would beClientRequest
and the associated types would be as follows:It would be great if it were possible to implement
Service
generically, specializing overR: lsp_types::Request
andN: lsp_types::Notification
and acceptingParams
from both as input, but this is impossible to express in the Rust type system, as far as I can tell. I think the above approach is good enough solution for our use case.We should think about whether
ClientRequest
should be redesigned to not include theid
field for requests, in favor of having theClient
manage it internally instead, using therequest_id
field. This prevents callers from submitting the same request ID twice, preventing accidental collisions and improving type safety.The text was updated successfully, but these errors were encountered: