sqlite_graphrag/output/passthrough.rs
1//! Unstructured stdout writers: plain text lines and verbatim bytes.
2//!
3//! Neither goes through [`crate::agent_surface`], and neither can — there is
4//! no envelope to reshape. `emit_raw` exists precisely so a memory body leaves
5//! the process byte for byte, which is the opposite of reshaping.
6
7use super::sink;
8
9/// Writes `msg` followed by a newline to stdout and flushes.
10///
11/// A `BrokenPipe` error is silenced gracefully.
12#[inline]
13pub fn emit_text(msg: &str) {
14 sink::write_line_lossy(msg.as_bytes());
15}
16
17/// GAP-SG-50: writes `bytes` to stdout verbatim, with no trailing newline and
18/// no JSON envelope. Used by `read --format raw` so the pure memory body can be
19/// piped without a `jaq -r '.body'` round-trip. A `BrokenPipe` error is
20/// silenced gracefully.
21#[inline]
22pub fn emit_raw(bytes: &[u8]) {
23 sink::write_verbatim(bytes);
24}