Struct ast_grep_lsp::Server
source · pub struct Server<I, O, L = ClientSocket> { /* private fields */ }Expand description
Server for processing requests and responses on standard I/O or TCP.
Implementations§
source§impl<I, O, L> Server<I, O, L>where
I: AsyncRead + Unpin,
O: AsyncWrite,
L: Loopback,
<<L as Loopback>::ResponseSink as Sink<Response>>::Error: Error,
impl<I, O, L> Server<I, O, L>where I: AsyncRead + Unpin, O: AsyncWrite, L: Loopback, <<L as Loopback>::ResponseSink as Sink<Response>>::Error: Error,
sourcepub fn new(stdin: I, stdout: O, socket: L) -> Server<I, O, L>
pub fn new(stdin: I, stdout: O, socket: L) -> Server<I, O, L>
Creates a new Server with the given stdin and stdout handles.
sourcepub fn concurrency_level(self, max: usize) -> Server<I, O, L>
pub fn concurrency_level(self, max: usize) -> Server<I, O, L>
Sets the server concurrency limit to max.
This setting specifies how many incoming requests may be processed concurrently. Setting
this value to 1 forces all requests to be processed sequentially, thereby implicitly
disabling support for the $/cancelRequest notification.
If not explicitly specified, max defaults to 4.
Preference over standard tower middleware
The ConcurrencyLimit and Buffer middlewares provided by tower rely on
tokio::spawn in common usage, while this library aims to be executor agnostic and to
support exotic targets currently incompatible with tokio, such as WASM. As such, Server
includes its own concurrency facilities that don’t require a global executor to be present.
sourcepub async fn serve<T>(self, service: T)where
T: Service<Request, Response = Option<Response>> + Send + 'static,
<T as Service<Request>>::Error: Into<Box<dyn Error + Send + Sync>>,
<T as Service<Request>>::Future: Send,
pub async fn serve<T>(self, service: T)where T: Service<Request, Response = Option<Response>> + Send + 'static, <T as Service<Request>>::Error: Into<Box<dyn Error + Send + Sync>>, <T as Service<Request>>::Future: Send,
Spawns the service with messages read through stdin and responses written to stdout.