pub struct Output { /* private fields */ }Expand description
The boundary a handler writes results through.
Implementations§
Source§impl Output
impl Output
Sourcepub const fn human() -> Self
pub const fn human() -> Self
The boundary for a command whose result is the document itself — a chapter, a binding, a license — where a JSON wrapper would add nothing an agent can use.
Sourcepub fn result_line(&self, line: impl AsRef<str>)
pub fn result_line(&self, line: impl AsRef<str>)
One human result line on stdout; silent under --json, where the
emitted document is the whole result.
Sourcepub fn result_raw(&self, text: &str)
pub fn result_raw(&self, text: &str)
A human result without a trailing newline, for byte-identical
payload prints; silent under --json.
Sourcepub fn result_bytes(&self, bytes: &[u8])
pub fn result_bytes(&self, bytes: &[u8])
A generated byte result — completions, and nothing else today — through the same pipe-safe path as every other result.
Sourcepub fn emit<T: Serialize>(&self, report: &T) -> Result<(), RkError>
pub fn emit<T: Serialize>(&self, report: &T) -> Result<(), RkError>
The machine result: one JSON document on stdout, and nothing in human mode.
§Errors
Returns RkError::Other when the report cannot serialize, which
is a defect in this binary rather than anything a caller can
correct.
Sourcepub fn event<T: Serialize>(&self, event: &T)
pub fn event<T: Serialize>(&self, event: &T)
One NDJSON event line on stdout under --json, and nothing in
human mode: the long-running commands’ machine stream, one complete
object per line.
Sourcepub fn frame(&self, line: impl AsRef<str>)
pub fn frame(&self, line: impl AsRef<str>)
One line of framing on stderr in human mode — step frames, the
command echo, warnings — and nothing under --json, where the
events carry the run.
Sourcepub fn child_passthrough(&self, stream: ChildStream, bytes: &[u8])
pub fn child_passthrough(&self, stream: ChildStream, bytes: &[u8])
Raw child bytes to the parent’s matching stream, human mode only: never swallow a subprocess, and never corrupt a pipe either.