Skip to main content

Module codec

Module codec 

Source
Expand description

Tokio-async codec gluing framing + jsonrpc onto AsyncBufRead / AsyncWrite. One read_message / write_message per LSP message.

§Read protocol (per message)

  1. Read header lines (CRLF-terminated, ASCII) until the empty \r\n terminator.
  2. Parse header block via crate::framing::parse_header_block.
  3. Read exactly content_length body bytes.
  4. Decode body as one crate::jsonrpc::Message.

§Write protocol (per message)

  1. JSON-encode the body (one allocation).
  2. Write Content-Length: N\r\n\r\n header.
  3. Write the body. Flush.

§Cancellation safety

Both read_message and write_message are cancel-safe at .await points only when the caller holds an exclusive reference. We don’t promise mid-message resumption – the actor wraps these in a single-task loop with no concurrent readers.

Structs§

LspReader
One-message-at-a-time async reader.
LspWriter
One-message-at-a-time async writer.

Enums§

CodecError
Combined error surface for the codec layer.