MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / write_message

Function write_message

src/diagnostics/lsp/client.rs:336–356  ·  view source on GitHub ↗
(stdin: &mut tokio::process::ChildStdin, value: Value)

Source from the content-addressed store, hash-verified

334}
335
336async fn write_message(stdin: &mut tokio::process::ChildStdin, value: Value) -> Result<()> {
337 let body = serde_json::to_vec(&value).map_err(|e| TraceDecayError::Config {
338 message: format!("failed to encode LSP message: {e}"),
339 })?;
340 let header = format!("Content-Length: {}\r\n\r\n", body.len());
341 stdin
342 .write_all(header.as_bytes())
343 .await
344 .map_err(|e| TraceDecayError::Config {
345 message: format!("failed to write LSP message: {e}"),
346 })?;
347 stdin
348 .write_all(&body)
349 .await
350 .map_err(|e| TraceDecayError::Config {
351 message: format!("failed to write LSP message: {e}"),
352 })?;
353 stdin.flush().await.map_err(|e| TraceDecayError::Config {
354 message: format!("failed to flush LSP message: {e}"),
355 })
356}
357
358async fn write_message_with_timeout(
359 stdin: &mut tokio::process::ChildStdin,

Callers 1

Calls 1

flushMethod · 0.45

Tested by

no test coverage detected