Struct tower_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: LanguageServer> LspService<S>
impl<S: LanguageServer> LspService<S>
sourcepub fn new<F>(init: F) -> (Self, ClientSocket)
pub fn new<F>(init: F) -> (Self, ClientSocket)
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>
pub fn build<F>(init: F) -> LspServiceBuilder<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> Debug for LspService<S>
impl<S: Debug> Debug for LspService<S>
source§impl<S: LanguageServer> Service<Request> for LspService<S>
impl<S: LanguageServer> Service<Request> for LspService<S>
§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>>
Auto Trait Implementations§
impl<S> Freeze for LspService<S>
impl<S> !RefUnwindSafe for LspService<S>
impl<S> Send for LspService<S>
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
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