pub struct ChildTransport { /* private fields */ }Expand description
One spawned LSP server process and its split codec halves.
Constructed by ChildTransport::spawn. After
ChildTransport::split the reader, writer, and child handle
can be moved into independent tasks. The actor pattern:
let t = ChildTransport::spawn("rust-analyzer", &[], None).await?;
let (reader, writer, child) = t.split();
tokio::spawn(read_loop(reader));
tokio::spawn(write_loop(writer, mailbox_rx));
// child handle stays with the supervisor for kill / wait.Implementations§
Source§impl ChildTransport
impl ChildTransport
Sourcepub async fn spawn<P, I, S>(
binary: P,
args: I,
cwd: Option<&Path>,
) -> Result<Self, TransportError>
pub async fn spawn<P, I, S>( binary: P, args: I, cwd: Option<&Path>, ) -> Result<Self, TransportError>
Spawn the server binary with the given args. cwd is the
working directory passed to the child; LSP servers
typically resolve workspace-relative paths against it.
Pass the resolved workspace root when known.
Sourcepub fn pid(&self) -> Option<u32>
pub fn pid(&self) -> Option<u32>
Process id of the spawned server. Useful for logs /
telemetry. None if the child has already been reaped.
Sourcepub fn split(
self,
) -> (LspReader<BufReader<ChildStdout>>, LspWriter<ChildStdin>, Option<ChildStderr>, Child)
pub fn split( self, ) -> (LspReader<BufReader<ChildStdout>>, LspWriter<ChildStdin>, Option<ChildStderr>, Child)
Consume the transport and return the reader, writer, and
retained child handle. The stderr pipe (if captured) is
returned alongside so the caller can spawn its own drain
task with whatever logging context is appropriate
(server_id, language, workspace root). This keeps the
transport free of tracing calls – the actor decides.
Sourcepub async fn kill(self) -> Result<(), TransportError>
pub async fn kill(self) -> Result<(), TransportError>
Force-kill the server process. The actor’s normal
shutdown path runs shutdown + exit LSP requests
instead; this is the supervision-layer fallback when the
server hangs.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ChildTransport
impl !UnwindSafe for ChildTransport
impl Freeze for ChildTransport
impl Send for ChildTransport
impl Sync for ChildTransport
impl Unpin for ChildTransport
impl UnsafeUnpin for ChildTransport
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> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more