Struct ast_grep_lsp::LspService
source · pub struct LspService<S> { /* private fields */ }Expand description
Service abstraction for the Language Server Protocol.
This service takes an incoming JSON-RPC message as input and produces an outgoing message as
output. If the incoming message is a server notification or a client response, then the
corresponding response will be None.
This implements [tower::Service] in order to remain independent from the underlying transport
and to facilitate further abstraction with middleware.
Pending requests can be canceled by issuing a $/cancelRequest notification.
The service shuts down and stops serving requests after the exit notification is received.
Implementations§
source§impl<S> LspService<S>where
S: LanguageServer,
impl<S> LspService<S>where S: LanguageServer,
sourcepub fn new<F>(init: F) -> (LspService<S>, ClientSocket)where
F: FnOnce(Client) -> S,
pub fn new<F>(init: F) -> (LspService<S>, ClientSocket)where F: FnOnce(Client) -> S,
Creates a new LspService with the given server backend, also returning a channel for
server-to-client communication.
sourcepub fn build<F>(init: F) -> LspServiceBuilder<S>where
F: FnOnce(Client) -> S,
pub fn build<F>(init: F) -> LspServiceBuilder<S>where F: FnOnce(Client) -> S,
Starts building a new LspService.
Returns an LspServiceBuilder, which allows adding custom JSON-RPC methods to the server.
Trait Implementations§
source§impl<S> Debug for LspService<S>where
S: Debug,
impl<S> Debug for LspService<S>where S: Debug,
source§impl<S> Service<Request> for LspService<S>where
S: LanguageServer,
impl<S> Service<Request> for LspService<S>where S: LanguageServer,
§type Error = ExitedError
type Error = ExitedError
§type Future = Pin<Box<dyn Future<Output = Result<<LspService<S> as Service<Request>>::Response, <LspService<S> as Service<Request>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<LspService<S> as Service<Request>>::Response, <LspService<S> as Service<Request>>::Error>> + Send>>
source§fn poll_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), <LspService<S> as Service<Request>>::Error>>
fn poll_ready( &mut self, cx: &mut Context<'_> ) -> Poll<Result<(), <LspService<S> as Service<Request>>::Error>>
Poll::Ready(Ok(())) when the service is able to process requests. Read moreAuto Trait Implementations§
impl<S> !RefUnwindSafe for LspService<S>
impl<S> Send for LspService<S>where S: Send + Sync,
impl<S> !Sync for LspService<S>
impl<S> Unpin for LspService<S>
impl<S> !UnwindSafe for LspService<S>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere T: Service<Request> + ?Sized,
§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where Self: Sized,
§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 instead§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where Self: Sized,
§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.§fn call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self: Sized,
Self::Error: Into<Box<dyn Error + Send + Sync>>,
S: Stream<Item = Request>,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S>where Self: Sized, Self::Error: Into<Box<dyn Error + Send + Sync>>, S: Stream<Item = Request>,
§fn and_then<F>(self, f: F) -> AndThen<Self, F>where
Self: Sized,
F: Clone,
fn and_then<F>(self, f: F) -> AndThen<Self, F>where Self: Sized, F: Clone,
poll_ready method. Read more§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>where
Self: Sized,
F: FnOnce(Self::Response) -> Response + Clone,
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>where Self: Sized, F: FnOnce(Self::Response) -> Response + Clone,
poll_ready method. Read more§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>where
Self: Sized,
F: FnOnce(Self::Error) -> Error + Clone,
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>where Self: Sized, F: FnOnce(Self::Error) -> Error + Clone,
poll_ready method. Read more§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>where
Self: Sized,
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>where Self: Sized, Error: From<Self::Error>, F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read more