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

Function read_byte_until

src/diagnostics/lsp/client.rs:492–524  ·  view source on GitHub ↗
(
    reader: &mut BufReader<tokio::process::ChildStdout>,
    deadline: tokio::time::Instant,
    partial_message: bool,
    timeouts: LspRefreshTimeouts,
)

Source from the content-addressed store, hash-verified

490}
491
492async fn read_byte_until(
493 reader: &mut BufReader<tokio::process::ChildStdout>,
494 deadline: tokio::time::Instant,
495 partial_message: bool,
496 timeouts: LspRefreshTimeouts,
497) -> Result<Option<u8>> {
498 let now = tokio::time::Instant::now();
499 if now >= deadline {
500 return if partial_message {
501 Err(refresh_timed_out(timeouts))
502 } else {
503 Ok(None)
504 };
505 }
506 let mut byte = [0_u8; 1];
507 match tokio::time::timeout(
508 deadline.saturating_duration_since(now),
509 reader.read(&mut byte),
510 )
511 .await
512 {
513 Ok(Ok(0)) if partial_message => Err(TraceDecayError::Config {
514 message: "LSP server closed before completing message header".to_string(),
515 }),
516 Ok(Ok(0)) => Ok(None),
517 Ok(Ok(_)) => Ok(Some(byte[0])),
518 Ok(Err(err)) => Err(TraceDecayError::Config {
519 message: format!("failed to read LSP header: {err}"),
520 }),
521 Err(_) if partial_message => Err(refresh_timed_out(timeouts)),
522 Err(_) => Ok(None),
523 }
524}
525
526fn file_uri(path: &Path) -> String {
527 let absolute = if path.is_absolute() {

Callers 1

read_message_untilFunction · 0.85

Calls 2

refresh_timed_outFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected