Expand description
LSP transport layer for perl-lsp.
This crate provides the transport layer implementation for the Perl Language Server, handling message framing according to the LSP Base Protocol specification.
§Overview
The LSP Base Protocol uses Content-Length based message framing over stdio (or other transports). This crate provides:
ContentLengthMessageReader- Stateful framed reader for streaming request loopsread_message- Read and parse an LSP message with Content-Length framingwrite_message- Write an LSP response with proper framingwrite_notification- Write an LSP notification with proper framinglog_response- Debug logging for outgoing responses
§Example
use std::io::{BufReader, stdin, stdout};
use perl_lsp_transport::{read_message, write_message};
use perl_lsp_protocol::JsonRpcResponse;
let mut reader = BufReader::new(stdin());
let mut writer = stdout();
// Read an incoming message
if let Ok(Some(request)) = read_message(&mut reader) {
// Process request and create response
let response = JsonRpcResponse::null(request.id);
// Write the response
write_message(&mut writer, &response)?;
}Structs§
- Content
Length Message Reader - Stateful reader for
Content-Lengthframed JSON-RPC requests.
Functions§
- frame
- Build a full
Content-Lengthframed message from a payload body. - log_
response - Log outgoing response metadata for transport debugging.
- read_
message - Read an LSP message from a buffered reader.
- write_
message - Write an LSP response with
Content-Lengthframing. - write_
notification - Write an LSP notification with
Content-Lengthframing.