Skip to main content

parse_daemon_to_client_messages

Function parse_daemon_to_client_messages 

pub fn parse_daemon_to_client_messages(
    buffer: &[u8],
) -> (Vec<DaemonToClientMessage>, Vec<u8>)
Expand description

Parse as many complete DaemonToClientMessages as possible from buffer.

The parser walks buffer from the start, decoding one tag-prefixed frame at a time. Parsing stops when fewer bytes remain than are needed to complete the next frame; the unconsumed tail is returned so the caller can prepend it to the next read.

§Arguments

  • buffer - Bytes received from the daemon’s named pipe, possibly including a partial trailing frame.

§Returns

A tuple of (messages, remainder) where messages are the fully decoded frames in arrival order and remainder holds the unconsumed bytes (an empty Vec if the buffer ended on a frame boundary).

§Panics

Panics if buffer contains a tag byte that is not part of the documented daemon-to-client protocol (see crate::protocol). An unknown tag indicates either a protocol-version mismatch between the daemon and client or corruption on the pipe – both unrecoverable, matching the codebase’s “broken bookkeeping -> panic” convention.