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)where
F: FnOnce(Client) -> S,
pub fn new<F>(init: F) -> (Self, 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> 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, Global>>
type Future = Pin<Box<dyn Future<Output = Result<<LspService<S> as Service<Request>>::Response, <LspService<S> as Service<Request>>::Error>> + Send, Global>>
Auto 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
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 Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere T: Service<Request> + ?Sized,
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 call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self: Sized,
Self::Error: Into<Box<dyn Error + Sync + Send, Global>>,
S: Stream<Item = Request>,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S>where Self: Sized, Self::Error: Into<Box<dyn Error + Sync + Send, Global>>, S: Stream<Item = Request>,
source§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 moresource§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 moresource§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 moresource§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