data.drivers._pelt._framing

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Sans-I/O framing: raw backend bytes → typedPGMessageobjects.

The single entry point isparse_message(), which reads one length-prefixed backend message from the front of a buffer and reports how many…

Sans-I/O framing: raw backend bytes → typedPGMessageobjects.

The single entry point isparse_message(), which reads one length-prefixed backend message from the front of a buffer and reports how many bytes it consumed.Nonemeans "need more data" — the caller carries the leftover bytes forward and tries again after the next read (cf. pounce_fast_h1.py / sync_protocol.py). This module touches no socket and no anyio, so it is fuzzable in isolation and parallelizable across free-threaded workers.

Robustness contract (proven by the E1 fuzz test): on any input,parse_message() either returns(message, consumed), returns (None, 0)for an incomplete buffer, or raisesProtocolError. It never raises anything else.

data.drivers._pelt._framing

Name Type Default Description
type —
qualified_name —
element_type —
description —
source_file —
line_number —
is_autodoc —
autodoc_element —
_autodoc_template —
_autodoc_url_path —
_autodoc_page_type —
title —
doc_content_hash —

Symbols on this page

_Reader
class

A bounded cursor over a single message payload. Every accessor raises ProtocolError on underflow, so parsers never see a raw IndexError.

parse_message
function
def parse_message(buf: bytes | memoryview) -> tuple[PGMessage | None, int]

Parse one backend message from the front ofbuf.

Returns(message, consumed) where consumedis the number of bytes the message occupied, or(None, 0) when bufdoes not yet hold a complete message. Raises ProtocolErroron a malformed header, an unknown tag, or a truncated/garbled payload.

Parameters

Name Type Default Description
buf bytes | memoryview —

View source · /home/runner/work/chirp/chirp/site/../src/chirp/data/drivers/_pelt/_framing.py:1